jrblevin / markdown-mode

Emacs Markdown Mode
http://jblevins.org/projects/markdown-mode/
GNU General Public License v3.0
877 stars 160 forks source link

"Wrong type argument: consp, nil" from imenu #578

Open sandinmyjoints opened 3 years ago

sandinmyjoints commented 3 years ago

Expected Behavior

Actual Behavior

Steps to Reproduce

  1. call imenu on a markdown-mode buffer with the following content:
# A

### B

## C

Backtrace

Software Versions

syohex commented 3 years ago

I cannot reproduce this issue with both Emacs 28.0.50(2021/01/05 master branch) and 27.1.

I did

Then no error happens. Could you tell us how to reproduce this issue in more detail ? cursor position, minimum configuration etc.

rien333 commented 3 years ago

Are you by any change using the native-comp branch from emacs 28? I had a similar issue with that branch (I don't recall how I fixed it at the moment, however)

sandinmyjoints commented 3 years ago

I am, yes! Would definitely be interested in your fix.

rien333 commented 3 years ago

I think that the following were among the steps that restored imenu to an usable state for me (in the context of markdown-mode):

  1. Make sure to have an up-to-date emacs 28
  2. Add (setq markdown-nested-imenu-heading-index nil) to your init.el

Why this works, I don't know. Could be that I did more stuff to fix this.

wyuenho commented 3 years ago

Does this issue really have to do with emacs 28?

rien333 commented 3 years ago

Yes, but only in so far emacs 28 introduced the native comp feature, which at one point broke some imenu stuff.

syohex commented 3 years ago

I still cannot reproduce this issue with emacs master branch(2021/04/30) with native comp build flag.

rien333 commented 3 years ago

@syohex could be that this (or some underlying) issue has been fixed by now, especially since the native-comp branch is under heavy development. In any case, I can't reproduce this issue anymore either.

syohex commented 3 years ago

Thanks for information. Please reopen if this issue happens again

wyuenho commented 3 years ago

I found this issue because I ran into it, please reopen. I'll report any debugging info here when I have some time to dig into it.

liuyinz commented 3 years ago

yes, several days ago,the problem seems fixed by emacs28,but it appeared again after I update the native-comp branch...

syohex commented 3 years ago

@wyuenho please try to latest code. And this issue is not markdown-mode issue. If you still have problem, please report issue to emacs development mailing list.

yuezhu commented 3 years ago

I can confirm this issue exists in GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin19.6.0, NS appkit-1894.60 Version 10.15.7 (Build 19H1217)) of 2021-06-23.

Setting markdown-nested-imenu-heading-index to nil can be a workaround.

wyuenho commented 3 years ago

@syohex @jrblevin Can you please reopen this? This is still happening.

syohex commented 3 years ago

Hmm, I cannot reproduce this issue latest emacs(enable native compile) version ? I think this is not markdown-mode issue as I said above. Could you report this issue emacs development mailing list ?

wyuenho commented 3 years ago

Just because you cannot reproduce it, it doesn't mean it's not a bug of this package.

The problem is you've created a circular list here.

hlissner commented 3 years ago

This issue persists, despite 359347b:

Debugger entered--Lisp error: (wrong-type-argument consp nil)
  markdown-imenu-create-nested-index()
  imenu--make-index-alist()
  imenu-choose-buffer-index()
  byte-code("\300 C\207" [imenu-choose-buffer-index] 1)
  command-execute(imenu record)
  execute-extended-command(nil "imenu" "imenu")
  funcall-interactively(execute-extended-command nil "imenu" "imenu")
  command-execute(execute-extended-command)

I'm using the latest commit (359347b) and can reproduce this in vanilla Emacs 28.0.50 (native-comp) with the Doom Emacs README.md open.

Used the same method to reproduce this as @syohex:

(setq markdown-nested-imenu-heading-index nil) is still an effective workaround.

EDIT: I am unable to reproduce this error in 27.2. EDIT 2: I am unable to reproduce this error in 28.0.50 (without native-comp).

wyuenho commented 3 years ago

Are you able to disassemble markdown-imenu-create-nested-index? I suspect this function might need to be rewritten.

hlissner commented 3 years ago

Sure. Curiously I can't reproduce this without native-comp, and the issue goes away if I re-evaluate its definition, so something is certainly lost at compile time. It may very well be an upstream issue.

Disassembled `markdown-imenu-create-nested-index` ```assembly 000000000002c400 : 2c400: 41 57 push %r15 2c402: 41 56 push %r14 2c404: 45 31 f6 xor %r14d,%r14d 2c407: 41 55 push %r13 2c409: 41 54 push %r12 2c40b: 55 push %rbp 2c40c: 53 push %rbx 2c40d: 48 81 ec 28 02 00 00 sub $0x228,%rsp 2c414: 48 8b 05 cd bb 06 00 mov 0x6bbcd(%rip),%rax # 97fe8 2c41b: 48 8b 2d be bb 06 00 mov 0x6bbbe(%rip),%rbp # 97fe0 2c422: 4c 8d 6c 24 38 lea 0x38(%rsp),%r13 2c427: 48 8b 18 mov (%rax),%rbx 2c42a: 4c 8b bd 28 15 00 00 mov 0x1528(%rbp),%r15 2c431: ff 53 20 callq *0x20(%rbx) 2c434: ff 93 98 13 00 00 callq *0x1398(%rbx) 2c43a: 48 89 c7 mov %rax,%rdi 2c43d: ff 93 60 14 00 00 callq *0x1460(%rbx) 2c443: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) 2c448: 48 8b bd 90 05 00 00 mov 0x590(%rbp),%rdi 2c44f: ff 93 78 25 00 00 callq *0x2578(%rbx) 2c455: 49 89 c4 mov %rax,%r12 2c458: ff 93 a0 13 00 00 callq *0x13a0(%rbx) 2c45e: 31 c9 xor %ecx,%ecx 2c460: 48 8b 95 f8 00 00 00 mov 0xf8(%rbp),%rdx 2c467: 4c 89 e7 mov %r12,%rdi 2c46a: 48 89 c6 mov %rax,%rsi 2c46d: ff 93 58 0e 00 00 callq *0xe58(%rbx) 2c473: 48 85 c0 test %rax,%rax 2c476: 0f 84 54 01 00 00 je 2c5d0 2c47c: 48 8b 85 60 05 00 00 mov 0x560(%rbp),%rax 2c483: 4c 89 ee mov %r13,%rsi 2c486: bf 01 00 00 00 mov $0x1,%edi 2c48b: 48 89 44 24 38 mov %rax,0x38(%rsp) 2c490: ff 93 b0 19 00 00 callq *0x19b0(%rbx) 2c496: 48 85 c0 test %rax,%rax 2c499: 74 0d je 2c4a8 2c49b: e8 80 5c fe ff callq 12120 2c4a0: eb a6 jmp 2c448 2c4a2: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) 2c4a8: bf 0e 00 00 00 mov $0xe,%edi 2c4ad: ff 93 30 0e 00 00 callq *0xe30(%rbx) 2c4b3: 48 85 c0 test %rax,%rax 2c4b6: 74 22 je 2c4da 2c4b8: bf 0e 00 00 00 mov $0xe,%edi 2c4bd: ff 93 30 0e 00 00 callq *0xe30(%rbx) 2c4c3: 31 d2 xor %edx,%edx 2c4c5: 48 8b b5 20 0b 00 00 mov 0xb20(%rbp),%rsi 2c4cc: 48 89 c7 mov %rax,%rdi 2c4cf: ff 93 40 0a 00 00 callq *0xa40(%rbx) 2c4d5: 48 85 c0 test %rax,%rax 2c4d8: 75 c1 jne 2c49b 2c4da: 48 8b 85 08 03 00 00 mov 0x308(%rbp),%rax 2c4e1: 48 8d b4 24 e0 00 00 lea 0xe0(%rsp),%rsi 2c4e8: 00 2c4e9: bf 02 00 00 00 mov $0x2,%edi 2c4ee: 48 c7 84 24 e8 00 00 movq $0xa,0xe8(%rsp) 2c4f5: 00 0a 00 00 00 2c4fa: 48 89 84 24 e0 00 00 mov %rax,0xe0(%rsp) 2c501: 00 2c502: ff 93 b0 19 00 00 callq *0x19b0(%rbx) 2c508: 48 85 c0 test %rax,%rax 2c50b: 48 8b 85 08 03 00 00 mov 0x308(%rbp),%rax 2c512: 0f 84 a0 03 00 00 je 2c8b8 2c518: 48 8d b4 24 80 01 00 lea 0x180(%rsp),%rsi 2c51f: 00 2c520: bf 02 00 00 00 mov $0x2,%edi 2c525: 48 89 84 24 80 01 00 mov %rax,0x180(%rsp) 2c52c: 00 2c52d: 41 bf 06 00 00 00 mov $0x6,%r15d 2c533: 48 c7 84 24 88 01 00 movq $0x6,0x188(%rsp) 2c53a: 00 06 00 00 00 2c53f: ff 93 b0 19 00 00 callq *0x19b0(%rbx) 2c545: bf 06 00 00 00 mov $0x6,%edi 2c54a: 49 89 c4 mov %rax,%r12 2c54d: ff 93 30 0e 00 00 callq *0xe30(%rbx) 2c553: 48 8b 95 68 15 00 00 mov 0x1568(%rbp),%rdx 2c55a: bf 06 00 00 00 mov $0x6,%edi 2c55f: 48 8b 8d 60 15 00 00 mov 0x1560(%rbp),%rcx 2c566: 48 8d b4 24 f0 01 00 lea 0x1f0(%rsp),%rsi 2c56d: 00 2c56e: 4c 89 a4 24 f8 01 00 mov %r12,0x1f8(%rsp) 2c575: 00 2c576: 48 89 94 24 f0 01 00 mov %rdx,0x1f0(%rsp) 2c57d: 00 2c57e: 48 8b 95 70 15 00 00 mov 0x1570(%rbp),%rdx 2c585: 48 89 8c 24 10 02 00 mov %rcx,0x210(%rsp) 2c58c: 00 2c58d: 48 89 94 24 00 02 00 mov %rdx,0x200(%rsp) 2c594: 00 2c595: 48 89 84 24 08 02 00 mov %rax,0x208(%rsp) 2c59c: 00 2c59d: 48 c7 84 24 18 02 00 movq $0x6,0x218(%rsp) 2c5a4: 00 06 00 00 00 2c5a9: ff 93 c0 1e 00 00 callq *0x1ec0(%rbx) 2c5af: 4c 89 f6 mov %r14,%rsi 2c5b2: 48 89 c7 mov %rax,%rdi 2c5b5: ff 93 c8 1e 00 00 callq *0x1ec8(%rbx) 2c5bb: 49 89 c6 mov %rax,%r14 2c5be: e8 5d 5b fe ff callq 12120 2c5c3: e9 80 fe ff ff jmpq 2c448 2c5c8: 0f 1f 84 00 00 00 00 nopl 0x0(%rax,%rax,1) 2c5cf: 00 2c5d0: 48 8b 45 20 mov 0x20(%rbp),%rax 2c5d4: 4c 8b 6d 30 mov 0x30(%rbp),%r13 2c5d8: 4c 89 f7 mov %r14,%rdi 2c5db: 48 89 44 24 08 mov %rax,0x8(%rsp) 2c5e0: ff 93 a8 21 00 00 callq *0x21a8(%rbx) 2c5e6: 48 8d 4c 24 70 lea 0x70(%rsp),%rcx 2c5eb: 49 89 c4 mov %rax,%r12 2c5ee: 8d 40 fd lea -0x3(%rax),%eax 2c5f1: 48 89 4c 24 28 mov %rcx,0x28(%rsp) 2c5f6: 48 8d 8c 24 b0 00 00 lea 0xb0(%rsp),%rcx 2c5fd: 00 2c5fe: a8 07 test $0x7,%al 2c600: 48 89 4c 24 20 mov %rcx,0x20(%rsp) 2c605: 0f 94 c0 sete %al 2c608: 0f b6 c0 movzbl %al,%eax 2c60b: 48 89 44 24 10 mov %rax,0x10(%rsp) 2c610: 0f 85 dc 00 00 00 jne 2c6f2 2c616: 48 83 bd f8 00 00 00 cmpq $0x0,0xf8(%rbp) 2c61d: 00 2c61e: 0f 84 ce 00 00 00 je 2c6f2 2c624: 4d 8b 7c 24 fd mov -0x3(%r12),%r15 2c629: 49 8d 44 24 fd lea -0x3(%r12),%rax 2c62e: 48 8b b5 60 15 00 00 mov 0x1560(%rbp),%rsi 2c635: 48 89 44 24 18 mov %rax,0x18(%rsp) 2c63a: 4c 89 ff mov %r15,%rdi 2c63d: ff 93 98 21 00 00 callq *0x2198(%rbx) 2c643: 48 8b b5 68 15 00 00 mov 0x1568(%rbp),%rsi 2c64a: 4c 89 ff mov %r15,%rdi 2c64d: 49 89 c6 mov %rax,%r14 2c650: ff 93 98 21 00 00 callq *0x2198(%rbx) 2c656: 48 8b b5 70 15 00 00 mov 0x1570(%rbp),%rsi 2c65d: 4c 89 ff mov %r15,%rdi 2c660: 49 89 c4 mov %rax,%r12 2c663: ff 93 98 21 00 00 callq *0x2198(%rbx) 2c669: 4c 89 e7 mov %r12,%rdi 2c66c: 48 89 c6 mov %rax,%rsi 2c66f: ff 93 c8 1e 00 00 callq *0x1ec8(%rbx) 2c675: 31 f6 xor %esi,%esi 2c677: 48 89 c7 mov %rax,%rdi 2c67a: ff 93 c8 1e 00 00 callq *0x1ec8(%rbx) 2c680: 4c 89 6c 24 70 mov %r13,0x70(%rsp) 2c685: 48 8b 74 24 28 mov 0x28(%rsp),%rsi 2c68a: bf 02 00 00 00 mov $0x2,%edi 2c68f: 4c 89 74 24 78 mov %r14,0x78(%rsp) 2c694: 49 89 c4 mov %rax,%r12 2c697: ff 93 00 25 00 00 callq *0x2500(%rbx) 2c69d: 48 85 c0 test %rax,%rax 2c6a0: 0f 84 f2 00 00 00 je 2c798 2c6a6: 48 8b 7c 24 08 mov 0x8(%rsp),%rdi 2c6ab: 4c 89 e6 mov %r12,%rsi 2c6ae: e8 ed 5b fe ff callq 122a0 2c6b3: 4c 89 64 24 08 mov %r12,0x8(%rsp) 2c6b8: 48 8b 44 24 18 mov 0x18(%rsp),%rax 2c6bd: 4c 8b 60 08 mov 0x8(%rax),%r12 2c6c1: e8 5a 5a fe ff callq 12120 2c6c6: 48 ba 00 00 00 00 ff movabs $0xffffffff00000000,%rdx 2c6cd: ff ff ff 2c6d0: 41 8d 44 24 fd lea -0x3(%r12),%eax 2c6d5: a8 07 test $0x7,%al 2c6d7: 0f 94 c0 sete %al 2c6da: 48 23 54 24 10 and 0x10(%rsp),%rdx 2c6df: 0f b6 c0 movzbl %al,%eax 2c6e2: 48 09 c2 or %rax,%rdx 2c6e5: 48 89 54 24 10 mov %rdx,0x10(%rsp) 2c6ea: 84 d2 test %dl,%dl 2c6ec: 0f 85 24 ff ff ff jne 2c616 2c6f2: 48 8b 95 38 15 00 00 mov 0x1538(%rbp),%rdx 2c6f9: 48 8d 74 24 40 lea 0x40(%rsp),%rsi 2c6fe: bf 02 00 00 00 mov $0x2,%edi 2c703: 48 8b 85 20 15 00 00 mov 0x1520(%rbp),%rax 2c70a: 48 89 54 24 40 mov %rdx,0x40(%rsp) 2c70f: 48 89 44 24 48 mov %rax,0x48(%rsp) 2c714: ff 93 b0 19 00 00 callq *0x19b0(%rbx) 2c71a: 48 8d 74 24 30 lea 0x30(%rsp),%rsi 2c71f: bf 01 00 00 00 mov $0x1,%edi 2c724: 49 89 c5 mov %rax,%r13 2c727: 48 8b 85 40 15 00 00 mov 0x1540(%rbp),%rax 2c72e: 48 89 44 24 30 mov %rax,0x30(%rsp) 2c733: ff 93 b0 19 00 00 callq *0x19b0(%rbx) 2c739: 48 89 c7 mov %rax,%rdi 2c73c: 49 89 c4 mov %rax,%r12 2c73f: ff 93 e8 22 00 00 callq *0x22e8(%rbx) 2c745: 48 8d 74 24 50 lea 0x50(%rsp),%rsi 2c74a: bf 02 00 00 00 mov $0x2,%edi 2c74f: 48 c7 44 24 58 02 00 movq $0x2,0x58(%rsp) 2c756: 00 00 2c758: 48 89 44 24 50 mov %rax,0x50(%rsp) 2c75d: ff 93 00 25 00 00 callq *0x2500(%rbx) 2c763: 48 85 c0 test %rax,%rax 2c766: 0f 84 f4 03 00 00 je 2cb60 2c76c: 4c 89 ef mov %r13,%rdi 2c76f: e8 dc 5a fe ff callq 12250 2c774: 49 89 c4 mov %rax,%r12 2c777: bf 06 00 00 00 mov $0x6,%edi 2c77c: ff 53 28 callq *0x28(%rbx) 2c77f: 48 81 c4 28 02 00 00 add $0x228,%rsp 2c786: 4c 89 e0 mov %r12,%rax 2c789: 5b pop %rbx 2c78a: 5d pop %rbp 2c78b: 41 5c pop %r12 2c78d: 41 5d pop %r13 2c78f: 41 5e pop %r14 2c791: 41 5f pop %r15 2c793: c3 retq 2c794: 0f 1f 40 00 nopl 0x0(%rax) 2c798: 4c 89 ac 24 80 00 00 mov %r13,0x80(%rsp) 2c79f: 00 2c7a0: 48 8d b4 24 80 00 00 lea 0x80(%rsp),%rsi 2c7a7: 00 2c7a8: bf 02 00 00 00 mov $0x2,%edi 2c7ad: 4c 89 b4 24 88 00 00 mov %r14,0x88(%rsp) 2c7b4: 00 2c7b5: ff 93 f8 24 00 00 callq *0x24f8(%rbx) 2c7bb: 48 85 c0 test %rax,%rax 2c7be: 0f 84 fc 03 00 00 je 2cbc0 2c7c4: 4c 89 ac 24 c8 00 00 mov %r13,0xc8(%rsp) 2c7cb: 00 2c7cc: 48 8d b4 24 c0 00 00 lea 0xc0(%rsp),%rsi 2c7d3: 00 2c7d4: bf 02 00 00 00 mov $0x2,%edi 2c7d9: 4c 8d bc 24 d0 00 00 lea 0xd0(%rsp),%r15 2c7e0: 00 2c7e1: 4c 89 b4 24 c0 00 00 mov %r14,0xc0(%rsp) 2c7e8: 00 2c7e9: ff 93 c8 24 00 00 callq *0x24c8(%rbx) 2c7ef: 48 89 c7 mov %rax,%rdi 2c7f2: e8 d9 59 fe ff callq 121d0 2c7f7: 4c 8b 6d 30 mov 0x30(%rbp),%r13 2c7fb: 48 89 04 24 mov %rax,(%rsp) 2c7ff: eb 35 jmp 2c836 2c801: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 2c808: 4c 89 e6 mov %r12,%rsi 2c80b: 48 8b bd f0 03 00 00 mov 0x3f0(%rbp),%rdi 2c812: ff 93 c8 1e 00 00 callq *0x1ec8(%rbx) 2c818: 31 f6 xor %esi,%esi 2c81a: 48 89 c7 mov %rax,%rdi 2c81d: ff 93 c8 1e 00 00 callq *0x1ec8(%rbx) 2c823: 4c 89 ef mov %r13,%rdi 2c826: 49 89 c4 mov %rax,%r12 2c829: e8 e2 59 fe ff callq 12210 2c82e: 49 89 c5 mov %rax,%r13 2c831: e8 ea 58 fe ff callq 12120 2c836: 48 8b 04 24 mov (%rsp),%rax 2c83a: 4c 89 ac 24 d0 00 00 mov %r13,0xd0(%rsp) 2c841: 00 2c842: 4c 89 fe mov %r15,%rsi 2c845: bf 02 00 00 00 mov $0x2,%edi 2c84a: 48 89 84 24 d8 00 00 mov %rax,0xd8(%rsp) 2c851: 00 2c852: ff 93 f8 24 00 00 callq *0x24f8(%rbx) 2c858: 48 85 c0 test %rax,%rax 2c85b: 75 ab jne 2c808 2c85d: 48 83 7c 24 08 00 cmpq $0x0,0x8(%rsp) 2c863: 0f 84 37 04 00 00 je 2cca0 2c869: 48 8b 7c 24 08 mov 0x8(%rsp),%rdi 2c86e: e8 0d 5b fe ff callq 12380 2c873: 48 89 c7 mov %rax,%rdi 2c876: 49 89 c5 mov %rax,%r13 2c879: e8 d2 59 fe ff callq 12250 2c87e: 48 8b bd 30 15 00 00 mov 0x1530(%rbp),%rdi 2c885: 48 89 c6 mov %rax,%rsi 2c888: ff 93 c8 1e 00 00 callq *0x1ec8(%rbx) 2c88e: 4c 89 e6 mov %r12,%rsi 2c891: 48 89 c7 mov %rax,%rdi 2c894: ff 93 c8 1e 00 00 callq *0x1ec8(%rbx) 2c89a: 4c 89 ef mov %r13,%rdi 2c89d: 4d 89 f5 mov %r14,%r13 2c8a0: 48 89 c6 mov %rax,%rsi 2c8a3: e8 f8 59 fe ff callq 122a0 2c8a8: 4c 89 64 24 08 mov %r12,0x8(%rsp) 2c8ad: e9 06 fe ff ff jmpq 2c6b8 2c8b2: 66 0f 1f 44 00 00 nopw 0x0(%rax,%rax,1) 2c8b8: 48 89 84 24 f0 00 00 mov %rax,0xf0(%rsp) 2c8bf: 00 2c8c0: 48 8d b4 24 f0 00 00 lea 0xf0(%rsp),%rsi 2c8c7: 00 2c8c8: bf 02 00 00 00 mov $0x2,%edi 2c8cd: 48 c7 84 24 f8 00 00 movq $0xe,0xf8(%rsp) 2c8d4: 00 0e 00 00 00 2c8d9: ff 93 b0 19 00 00 callq *0x19b0(%rbx) 2c8df: 48 85 c0 test %rax,%rax 2c8e2: 0f 84 10 01 00 00 je 2c9f8 2c8e8: 4c 89 bc 24 50 01 00 mov %r15,0x150(%rsp) 2c8ef: 00 2c8f0: 48 8d b4 24 50 01 00 lea 0x150(%rsp),%rsi 2c8f7: 00 2c8f8: bf 02 00 00 00 mov $0x2,%edi 2c8fd: 48 c7 84 24 58 01 00 movq $0xa,0x158(%rsp) 2c904: 00 0a 00 00 00 2c909: ff 93 98 24 00 00 callq *0x2498(%rbx) 2c90f: 48 8d b4 24 60 01 00 lea 0x160(%rsp),%rsi 2c916: 00 2c917: bf 02 00 00 00 mov $0x2,%edi 2c91c: 48 c7 84 24 68 01 00 movq $0x6,0x168(%rsp) 2c923: 00 06 00 00 00 2c928: 49 89 c7 mov %rax,%r15 2c92b: 48 8b 85 08 03 00 00 mov 0x308(%rbp),%rax 2c932: 48 89 84 24 60 01 00 mov %rax,0x160(%rsp) 2c939: 00 2c93a: ff 93 b0 19 00 00 callq *0x19b0(%rbx) 2c940: bf 06 00 00 00 mov $0x6,%edi 2c945: 48 89 04 24 mov %rax,(%rsp) 2c949: ff 93 30 0e 00 00 callq *0xe30(%rbx) 2c94f: 4c 89 ff mov %r15,%rdi 2c952: 49 89 c4 mov %rax,%r12 2c955: e8 76 58 fe ff callq 121d0 2c95a: 48 8d b4 24 70 01 00 lea 0x170(%rsp),%rsi 2c961: 00 2c962: bf 02 00 00 00 mov $0x2,%edi 2c967: 48 c7 84 24 70 01 00 movq $0xa,0x170(%rsp) 2c96e: 00 0a 00 00 00 2c973: 48 89 84 24 78 01 00 mov %rax,0x178(%rsp) 2c97a: 00 2c97b: ff 93 c8 24 00 00 callq *0x24c8(%rbx) 2c981: 48 8b 14 24 mov (%rsp),%rdx 2c985: 48 8b 8d 68 15 00 00 mov 0x1568(%rbp),%rcx 2c98c: 4c 89 a4 24 d8 01 00 mov %r12,0x1d8(%rsp) 2c993: 00 2c994: 48 89 84 24 e8 01 00 mov %rax,0x1e8(%rsp) 2c99b: 00 2c99c: 48 8d b4 24 c0 01 00 lea 0x1c0(%rsp),%rsi 2c9a3: 00 2c9a4: 48 89 94 24 c8 01 00 mov %rdx,0x1c8(%rsp) 2c9ab: 00 2c9ac: 48 8b 95 70 15 00 00 mov 0x1570(%rbp),%rdx 2c9b3: 48 89 8c 24 c0 01 00 mov %rcx,0x1c0(%rsp) 2c9ba: 00 2c9bb: 48 89 94 24 d0 01 00 mov %rdx,0x1d0(%rsp) 2c9c2: 00 2c9c3: 48 8b 95 60 15 00 00 mov 0x1560(%rbp),%rdx 2c9ca: 48 89 94 24 e0 01 00 mov %rdx,0x1e0(%rsp) 2c9d1: 00 2c9d2: bf 06 00 00 00 mov $0x6,%edi 2c9d7: ff 93 c0 1e 00 00 callq *0x1ec0(%rbx) 2c9dd: 4c 89 f6 mov %r14,%rsi 2c9e0: 48 89 c7 mov %rax,%rdi 2c9e3: ff 93 c8 1e 00 00 callq *0x1ec8(%rbx) 2c9e9: 49 89 c6 mov %rax,%r14 2c9ec: e9 aa fa ff ff jmpq 2c49b 2c9f1: 0f 1f 80 00 00 00 00 nopl 0x0(%rax) 2c9f8: 48 8b 85 08 03 00 00 mov 0x308(%rbp),%rax 2c9ff: 48 8d b4 24 00 01 00 lea 0x100(%rsp),%rsi 2ca06: 00 2ca07: bf 02 00 00 00 mov $0x2,%edi 2ca0c: 48 c7 84 24 08 01 00 movq $0x12,0x108(%rsp) 2ca13: 00 12 00 00 00 2ca18: 48 89 84 24 00 01 00 mov %rax,0x100(%rsp) 2ca1f: 00 2ca20: ff 93 b0 19 00 00 callq *0x19b0(%rbx) 2ca26: 48 8b 95 a0 05 00 00 mov 0x5a0(%rbp),%rdx 2ca2d: bf 02 00 00 00 mov $0x2,%edi 2ca32: 48 8d b4 24 10 01 00 lea 0x110(%rsp),%rsi 2ca39: 00 2ca3a: 48 89 84 24 18 01 00 mov %rax,0x118(%rsp) 2ca41: 00 2ca42: 48 89 94 24 10 01 00 mov %rdx,0x110(%rsp) 2ca49: 00 2ca4a: ff 93 b0 19 00 00 callq *0x19b0(%rbx) 2ca50: 49 89 c4 mov %rax,%r12 2ca53: 48 85 c0 test %rax,%rax 2ca56: 0f 84 3f fa ff ff je 2c49b 2ca5c: 48 89 c7 mov %rax,%rdi 2ca5f: ff 93 e8 22 00 00 callq *0x22e8(%rbx) 2ca65: 4c 89 bc 24 20 01 00 mov %r15,0x120(%rsp) 2ca6c: 00 2ca6d: bf 02 00 00 00 mov $0x2,%edi 2ca72: 48 8d b4 24 20 01 00 lea 0x120(%rsp),%rsi 2ca79: 00 2ca7a: 48 89 84 24 28 01 00 mov %rax,0x128(%rsp) 2ca81: 00 2ca82: ff 93 98 24 00 00 callq *0x2498(%rbx) 2ca88: 48 8d b4 24 30 01 00 lea 0x130(%rsp),%rsi 2ca8f: 00 2ca90: bf 02 00 00 00 mov $0x2,%edi 2ca95: 48 c7 84 24 38 01 00 movq $0x16,0x138(%rsp) 2ca9c: 00 16 00 00 00 2caa1: 49 89 c7 mov %rax,%r15 2caa4: 48 8b 85 08 03 00 00 mov 0x308(%rbp),%rax 2caab: 48 89 84 24 30 01 00 mov %rax,0x130(%rsp) 2cab2: 00 2cab3: ff 93 b0 19 00 00 callq *0x19b0(%rbx) 2cab9: bf 12 00 00 00 mov $0x12,%edi 2cabe: 48 89 44 24 08 mov %rax,0x8(%rsp) 2cac3: ff 93 30 0e 00 00 callq *0xe30(%rbx) 2cac9: 4c 89 e7 mov %r12,%rdi 2cacc: 48 89 04 24 mov %rax,(%rsp) 2cad0: ff 93 e8 22 00 00 callq *0x22e8(%rbx) 2cad6: 4c 89 ff mov %r15,%rdi 2cad9: 49 89 c4 mov %rax,%r12 2cadc: e8 ef 56 fe ff callq 121d0 2cae1: 48 8d b4 24 40 01 00 lea 0x140(%rsp),%rsi 2cae8: 00 2cae9: bf 02 00 00 00 mov $0x2,%edi 2caee: 4c 89 a4 24 40 01 00 mov %r12,0x140(%rsp) 2caf5: 00 2caf6: 48 89 84 24 48 01 00 mov %rax,0x148(%rsp) 2cafd: 00 2cafe: ff 93 c8 24 00 00 callq *0x24c8(%rbx) 2cb04: 48 8b 4c 24 08 mov 0x8(%rsp),%rcx 2cb09: 48 8b 14 24 mov (%rsp),%rdx 2cb0d: 48 8b b5 68 15 00 00 mov 0x1568(%rbp),%rsi 2cb14: 48 89 84 24 b8 01 00 mov %rax,0x1b8(%rsp) 2cb1b: 00 2cb1c: 48 89 8c 24 98 01 00 mov %rcx,0x198(%rsp) 2cb23: 00 2cb24: 48 8b 8d 70 15 00 00 mov 0x1570(%rbp),%rcx 2cb2b: 48 89 94 24 a8 01 00 mov %rdx,0x1a8(%rsp) 2cb32: 00 2cb33: 48 8b 95 60 15 00 00 mov 0x1560(%rbp),%rdx 2cb3a: 48 89 b4 24 90 01 00 mov %rsi,0x190(%rsp) 2cb41: 00 2cb42: 48 8d b4 24 90 01 00 lea 0x190(%rsp),%rsi 2cb49: 00 2cb4a: 48 89 8c 24 a0 01 00 mov %rcx,0x1a0(%rsp) 2cb51: 00 2cb52: 48 89 94 24 b0 01 00 mov %rdx,0x1b0(%rsp) 2cb59: 00 2cb5a: e9 73 fe ff ff jmpq 2c9d2 2cb5f: 90 nop 2cb60: 48 8b bd 48 15 00 00 mov 0x1548(%rbp),%rdi 2cb67: ff 93 78 25 00 00 callq *0x2578(%rbx) 2cb6d: 48 85 c0 test %rax,%rax 2cb70: 0f 84 f6 fb ff ff je 2c76c 2cb76: 4c 89 ef mov %r13,%rdi 2cb79: e8 d2 56 fe ff callq 12250 2cb7e: 4c 89 e6 mov %r12,%rsi 2cb81: 48 8b bd 50 15 00 00 mov 0x1550(%rbp),%rdi 2cb88: 49 89 c5 mov %rax,%r13 2cb8b: ff 93 c8 1e 00 00 callq *0x1ec8(%rbx) 2cb91: 31 f6 xor %esi,%esi 2cb93: 48 89 c7 mov %rax,%rdi 2cb96: ff 93 c8 1e 00 00 callq *0x1ec8(%rbx) 2cb9c: 4c 89 6c 24 60 mov %r13,0x60(%rsp) 2cba1: 48 8d 74 24 60 lea 0x60(%rsp),%rsi 2cba6: bf 02 00 00 00 mov $0x2,%edi 2cbab: 48 89 44 24 68 mov %rax,0x68(%rsp) 2cbb0: ff 93 40 21 00 00 callq *0x2140(%rbx) 2cbb6: 49 89 c4 mov %rax,%r12 2cbb9: e9 b9 fb ff ff jmpq 2c777 2cbbe: 66 90 xchg %ax,%ax 2cbc0: 48 8b 85 78 15 00 00 mov 0x1578(%rbp),%rax 2cbc7: 48 8d b4 24 90 00 00 lea 0x90(%rsp),%rsi 2cbce: 00 2cbcf: bf 02 00 00 00 mov $0x2,%edi 2cbd4: 48 c7 84 24 98 00 00 movq $0x0,0x98(%rsp) 2cbdb: 00 00 00 00 00 2cbe0: 48 89 84 24 90 00 00 mov %rax,0x90(%rsp) 2cbe7: 00 2cbe8: ff 93 b0 19 00 00 callq *0x19b0(%rbx) 2cbee: 4c 89 f7 mov %r14,%rdi 2cbf1: 49 89 c7 mov %rax,%r15 2cbf4: e8 d7 55 fe ff callq 121d0 2cbf9: 4c 8b 6d 30 mov 0x30(%rbp),%r13 2cbfd: 48 89 04 24 mov %rax,(%rsp) 2cc01: 48 8d 84 24 a0 00 00 lea 0xa0(%rsp),%rax 2cc08: 00 2cc09: 48 89 44 24 08 mov %rax,0x8(%rsp) 2cc0e: eb 4a jmp 2cc5a 2cc10: 4c 89 ff mov %r15,%rdi 2cc13: e8 68 57 fe ff callq 12380 2cc18: 48 89 c7 mov %rax,%rdi 2cc1b: e8 30 56 fe ff callq 12250 2cc20: 48 8b 74 24 20 mov 0x20(%rsp),%rsi 2cc25: bf 02 00 00 00 mov $0x2,%edi 2cc2a: 48 8b 95 78 15 00 00 mov 0x1578(%rbp),%rdx 2cc31: 48 89 84 24 b8 00 00 mov %rax,0xb8(%rsp) 2cc38: 00 2cc39: 48 89 94 24 b0 00 00 mov %rdx,0xb0(%rsp) 2cc40: 00 2cc41: ff 93 b0 19 00 00 callq *0x19b0(%rbx) 2cc47: 4c 89 ef mov %r13,%rdi 2cc4a: 49 89 c7 mov %rax,%r15 2cc4d: e8 be 55 fe ff callq 12210 2cc52: 49 89 c5 mov %rax,%r13 2cc55: e8 c6 54 fe ff callq 12120 2cc5a: 48 8b 04 24 mov (%rsp),%rax 2cc5e: 48 8b 74 24 08 mov 0x8(%rsp),%rsi 2cc63: bf 02 00 00 00 mov $0x2,%edi 2cc68: 4c 89 ac 24 a0 00 00 mov %r13,0xa0(%rsp) 2cc6f: 00 2cc70: 48 89 84 24 a8 00 00 mov %rax,0xa8(%rsp) 2cc77: 00 2cc78: ff 93 f8 24 00 00 callq *0x24f8(%rbx) 2cc7e: 48 85 c0 test %rax,%rax 2cc81: 75 8d jne 2cc10 2cc83: 4c 89 e6 mov %r12,%rsi 2cc86: 4c 89 ff mov %r15,%rdi 2cc89: 4d 89 f5 mov %r14,%r13 2cc8c: e8 0f 56 fe ff callq 122a0 2cc91: 4c 89 64 24 08 mov %r12,0x8(%rsp) 2cc96: e9 1d fa ff ff jmpq 2c6b8 2cc9b: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1) 2cca0: 48 8b bd 20 15 00 00 mov 0x1520(%rbp),%rdi 2cca7: 4c 89 e6 mov %r12,%rsi 2ccaa: 4d 89 f5 mov %r14,%r13 2ccad: e8 ee 55 fe ff callq 122a0 2ccb2: 4c 89 64 24 08 mov %r12,0x8(%rsp) 2ccb7: e9 fc f9 ff ff jmpq 2c6b8 2ccbc: 0f 1f 40 00 nopl 0x0(%rax) ```
wyuenho commented 3 years ago

the issue goes away if I re-evaluate its definition

Yes, I have the same problem.

Thanks for the disassembly. Let me ask emacs-devel how to compare the disassembled native code and byte code.

wyuenho commented 2 years ago

Ok I've just reproduced this again, this problem still persists, and can be seen by opening a markdown file that contains this:

# hello

hello
-----

world
=====

If you remove the last title (world) the problem goes away. @syohex can you reopen this?

cpbotha commented 2 years ago

I've just confirmed that this issue still occurs with an Emacs I built from the main branch just now (up to commit 72b5b4194106d38432cd9892bc01e95d71bf75db "Don't overwrite variables set by callback in help--window-setup" by Lars Ingebrigtsen larsi@gnus.org dated Fri May 13 19:31:46 2022 +0200), with native-compilation.

As was reported by others, re-evaluating the function in markdown-mode.el fixes it for that session.

However, the more permanent work-around I've done here is as follows:

  1. Add (setq native-comp-deferred-compilation-deny-list '("markdown-mode\\.el$")) to your init.el, before markdown-mode is loaded / used. Do see comment https://github.com/jrblevin/markdown-mode/issues/578#issuecomment-1442806105 by @uqix : On newer Emacsen, the variable is native-comp-jit-compilation-deny-list.
  2. Exit Emacs
  3. remove markdown-mode*.eln from the relevant directory in your .emacs.d/eln-cache/.
  4. Start Emacs

This prevents markdown-mode.el from being native-compiled, and hence defun markdown-imenu-create-nested-index works as it should.

uqix commented 1 year ago

I've just confirmed that this issue still occurs with an Emacs I built from the main branch just now (up to commit 72b5b4194106d38432cd9892bc01e95d71bf75db "Don't overwrite variables set by callback in help--window-setup" by Lars Ingebrigtsen larsi@gnus.org dated Fri May 13 19:31:46 2022 +0200), with native-compilation.

As was reported by others, re-evaluating the function in markdown-mode.el fixes it for that session.

However, the more permanent work-around I've done here is as follows:

  1. Add (setq native-comp-deferred-compilation-deny-list '("markdown-mode\\.el$")) to your init.el, before markdown-mode is loaded / used.
  2. Exit Emacs
  3. remove markdown-mode*.eln from the relevant directory in your .emacs.d/eln-cache/.
  4. Start Emacs

This prevents markdown-mode.el from being native-compiled, and hence defun markdown-imenu-create-nested-index works as it should.

for GNU Emacs 29.0.60 (build 1, x86_64-apple-darwin22.3.0, NS appkit-2299.40 Version 13.2.1 (Build 22D68)) of 2023-02-24, I need to change (setq native-comp-deferred-compilation-deny-list '("markdown-mode\\.el$")) to (setq native-comp-jit-compilation-deny-list '("markdown-mode\\.el$")).

kommen commented 1 year ago

I can confirm this issue persists with GNU Emacs 29.0.90 (build 1, aarch64-apple-darwin22.4.0, NS appkit-2299.50 Version 13.3.1 (a) (Build 22E772610a)) of 2023-05-03 with nativecomp. Reproduces with the Markdown file from this comment above.

The culprit seems to be (setcdr sibling-alist alist), as removing this form makes markdown-imenu-create-nested-index not crash.

wyuenho commented 1 year ago

I have opened https://debbugs.gnu.org/cgi/bugreport.cgi?bug=63564

kommen commented 1 year ago

@wyuenho thank you! as per Mattias' comment on your bugreport, I tried to reproduce with newest markdown-mode commit 1535b95 and with that can no longer reproduce the issue. I can still reproduce with markdown-mode cdac22a7, so it seems this was indeed fixed with yesterdays 44f0e8953

wyuenho commented 1 year ago

That is wonderful news, would still be nice to know why the nativecomp code and byte compiled code execute differently tho