Subject: Re: bug#56643: 29.0.50; Help-mode bookmarks not loading with native compilation

From: Eli Zaretskii <[email-masked]>
Date: Tue, 19 Jul 2022 19:49:23 +0300

> Date: Tue, 19 Jul 2022 13:45:19 +0000
> From: defun.foo--- via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> 1. Ensure that native compilation is enabled by running M-x native-comp-available-p
> 2. Run M-x describe-function {{any-function}} and move to the resulting *Help* buffer
> 3. Create a bookmark with C-x r m
> 4. Without quitting Emacs, kill the *Help* buffer, then run C-x r b to jump back to the bookmark (this works as expected)
> 5. Quit Emacs (C-x C-c), and restart
> 6. Attempt to jump to the same bookmark again (running C-x r b), and observe that the bookmark list fails to load and throws an "Invalid read syntax: '#'" error
> 
> Here is an example of a help bookmark as it was serialized to the bookmarks file (note the "help-fn" value):
> 
> ("native-comp-bookmark"
>  (position . 1)
>  (last-modified 25301 49750 590832 312000)
>  (help-fn . #<subr F616e6f6e796d6f75732d6c616d626461_anonymous_lambda_9>)
>  (help-args switch-to-buffer "*scratch*")
>  (position . 1)
>  (handler . help-bookmark-jump))
> 
> For comparison, I compiled Emacs without the native compilation flag (and verified that native-comp-available-p returned nil), and went through the same steps above, creating a new bookmark. Jumping back to the bookmark after restarting works as expected, and here is an example of that bookmark serialized without native comp:
> 
> ("vanilla-bookmark"
>  (position . 1)
>  (last-modified 25301 49238 861856 736000)
>  (help-fn .
>           #[514 "\301!\205\0\211\302!)\207"
>                 [describe-function-orig-buffer buffer-live-p describe-function]
>                 4 "\n\n(fn FUNCTION BUFFER)"])
>  (help-args switch-to-buffer "*scratch*")
>  (position . 1)
>  (handler . help-bookmark-jump))

Thanks.

I started looking into this, but gave up when I got to help-mode.el
(which is where the bookmark support for *Help* lives, and which is
where we signal an error trying to read an unreadable object.)

We basically have no usable documentation for what bookmark support in
help-mode does.  Someone who knows what that code does will have to
see how to process a help-fn that is a natively-compiled function.