On Wed, Jul 28, 2021 at 8:20 AM Andrea Corallo <firstname.lastname@example.org
Jimmy Yuen Ho Wong <email@example.com> writes:
> On 28/07/2021 3:09 AM, Jimmy Yuen Ho Wong wrote:
> I think I've found out what that stacktrace means. The regular _expression_ in disassemble-internal hasn't taken into
> account LLVM's objdump output format for mach-o objects. The first couple of lines of the *Disassemble* buffer looks
> like this on macOS:
> /Users/wyuenho/.emacs.d/eln-cache/28_0_50-83d1a9b9/markdown-mode-4888e153-14d4f01e.eln: file format mach-o 64-bit
> Disassembly of section __TEXT,__text:
> 0000000000002fa0 <_maybe_gc_quit>:
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/objdump: warning:
> '/Users/wyuenho/.emacs.d/eln-cache/28_0_50-83d1a9b9/markdown-mode-4888e153-14d4f01e.eln': failed to parse debug
> information for /Users/wyuenho/.emacs.d/eln-cache/28_0_50-83d1a9b9/markdown-mode-4888e153-14d4f01e.eln
> 2fa0: 8b 05 86 9f 08 00 movl 565126(%rip), %eax # 8cf2c <_quitcounter>
> 2fa6: 83 c0 01 addl $1, %eax
> On Tue, Jul 27, 2021 at 10:28 AM Andrea Corallo <firstname.lastname@example.org> wrote:
> Jimmy Yuen Ho Wong <email@example.com> writes:
> > I'm not exactly sure how to even ask this question, as I've seen various packages fail to natively compile
> circular lists
> > or optimize it wrongly. So I've come up with a simple test case for me to be able to disassemble the bytecode
> and the
> > native code, and see if I could spot the problem, but disassembling natively compiled code doesn't seem to
> > Test case:
> > (defun test-circular-list ()
> > (let ((l (list 1 2 3)))
> > (setcdr (last l) l)
> > l))
> > (print (test-circular-list))
> > (provide 'test-circular-list)
> > M-x emacs-lisp-byte-compile-and-load
> > M-x disassemble RET test-circular-list (works)
> > M-x emacs-lisp-native-compile-and-load
> > M-x disassemble RET test-circular-list (doesn't work)
> > Debugger entered--Lisp error: (search-failed "^.*<F746573742d63697263756c61722d6c697374_test_cir...")
> > re-search-forward("^.*<F746573742d63697263756c61722d6c697374_test_cir...")
> > disassemble-internal(test-circular-list 0 nil)
> > disassemble(test-circular-list nil 0 t)
> > funcall-interactively(disassemble test-circular-list nil 0 t)
> > command-execute(disassemble record)
> > execute-extended-command(nil "disassemble" nil)
> > funcall-interactively(execute-extended-command nil "disassemble" nil)
> > command-execute(execute-extended-command)
> > Furthermore, this test case, though superficially similar, doesn't seem to be able to reproduce the same
> failure to
> > natively compile issue as seen in powerline.
> > There seems to be more than one thing wrong with this journey into my deep dive into how native compiling
> circular lists
> > work.
> > Jimmy Yuen Ho Wong
> Hi Jimmy,
> I'm failing to reproduce this issue.
> Disassembling following your instructions works here. Also the compiled
> `test-circular-list' function as expected here.
> Am I missing something?
> Best Regards
> Sorry wrong patch from the last email. This is the correct one.
[re-adding the list]
thanks for the patch.
So I guess is clear this is unrelated to circular lists and probably
disassemble is just broken for every native compiled function in this
We might have other architecture+OS where function labels start with '_'
but so far the patch LGTM, I just suggest a small nit.
> diff --git a/lisp/emacs-lisp/disass.el b/lisp/emacs-lisp/disass.el
> index 6ac76f1c19..d0e3bf7bf4 100644
> --- a/lisp/emacs-lisp/disass.el
> +++ b/lisp/emacs-lisp/disass.el
> @@ -95,6 +95,7 @@ disassemble-internal
> (re-search-forward (concat "^.*"
> (concat "<"
> + (if (eq system-type 'darwin) "_")
I'd use `when' here.
> (subr-name obj) "F" t)
Do you aready have copyright assignment?
I do have an existing copyright assignment. No objection to using a when there, would you like me to submit a new patch or you are fine with editing it yourself?
As to whether this is related to circular lists, I'm not so sure yet. There's definitely something in native compilation that compiles code that behaves differently when circular lists are involved, I just haven't found out what interaction with circular lists will result in compilation failure or optimizing the result away. Any clues for what I should try is much appreciated.