adsr/mle

Popping a keymap when on the bottom of the mode stack causes a segmentation fault

mvousden opened this issue · 5 comments

I have a custom key mode on top of mle_normal. When I pop twice from this mode, mle segfaults. The first pop functions as expected, dropping me back to mle_normal.

Not sure what your stance on segmentation faults is, but it might be frustrating to lose a document this way!

adsr commented

Hi, let's definitely fix that. Can you send me your config or otherwise make a repro case? I couldn't reproduce on trunk with this:

mle -N -K test_kmap,,1 -k cmd_push_kmap,f8,test_kmap -k cmd_pop_kmap,f9, -n test_kmap

I hit f8, then f9 3 times. valgrind is clean.

As a simpler case, I can reproduce the segfault without using a config file. I start mle with mle -N (so I'm in mle_normal), then command M-x P, which causes the segfault.

For reference, I'm on e86c1be.

I've attached my output from Valgrind (3.18.1). The segfault happens at the "Invalid read of size 8".

mle_issue_0059_valgrind_out.txt

Also, thank you for this wonderful text editor 👍

adsr commented

I can reproduce. Debugging now.

adsr commented

b23943c should fix. Feel free to re-open if it doesn't. Not easy to write a test for this one as the test framework relies on a non-root kmap. Thanks @mvousden.

I confirm b23943c fixes the issue - when one now attempts to pop on the root kmap, nothing happens.

Thanks!