Subject: Re: bug#76039: 31.0.50; feature/igc (f356a5529be): Crash on Linux/Wayland Kde plasma6 (with full gdb debug info: build by -O3 -g3 -ggdb -march=native)

From: Pip Cet <[email-masked]>
Date: Tue, 04 Feb 2025 10:33:12 +0000

"Eval EXEC" <[email-masked]> writes:

> Hello,
>
> I'm helping test feature/igc branch, I  build emacs by:
>
> #!/usr/bin/env bash
> set -ex
>
> make extraclean
>
> BRANCH_NAME=$(git branch --show-current | sed 's/\//_/g')
> COMMIT_ID=$(git rev-parse HEAD)
> BUILD_DIR=${BRANCH_NAME}-${COMMIT_ID}-O3g3gdb
> INSTALL_PREFIX=$(realpath ../emacs-build/${BUILD_DIR})
>
> ./autogen.sh
> ./configure  CFLAGS='-O3 -g3 -ggdb -march=native' \
>   --prefix=${INSTALL_PREFIX} \
>   --with-imagemagick  \
>   --with-xwidgets \
>   --with-mps=yes \
>   --with-modules \
>   --with-cairo --with-cairo-xcb \
>   --without-compress-install \
>   --with-mailutils\
>   --with-tree-sitter --with-xinput2 \
>   --with-dbus \
>   --with-native-compilation=aot \
>   --enable-link-time-optimization \
>   --with-file-notification=inotify\
>   && make -j20 install
>
>
> Then I got a crash: bellow is full gdb backtrace.

Thanks for the report!

Were you using keyboard macros at the time?

> #11 deregister_root (r=0x0) at /home/exec/Projects/git.savannah.gnu.org/git/emacs/src/igc.c:1060
>         root = <optimized out>
>         root = <optimized out>
> #12 destroy_root (r=<synthetic pointer>) at /home/exec/Projects/git.savannah.gnu.org/git/emacs/src/igc.c:1070
> No locals.
> #13 igc_destroy_root_with_start (start=0x1e6dfdb0) at /home/exec/Projects/git.savannah.gnu.org/git/emacs/src/igc.c:3034
>         r = 0x0
> #14 igc_xnrealloc_ambig (pa=0x1e6dfdb0, nitems=30, item_size=8) at /home/exec/Projects/git.savannah.gnu.org/git/emacs/src/igc.c:3323
>         end = <optimized out>
>         i = 1
> #15 0x000000000062caea in Fstart_kbd_macro (append=XIL(0), no_exec=XIL(0)) at /home/exec/Projects/git.savannah.gnu.org/git/emacs/src/macros.c:74
> No locals.

This looks fairly obvious to me: kb->kbd_macro_buffer is resized with
igc_xnrealloc_ambig, but it was allocated with plain xpalloc.

I've pushed a fix and am, optimistically, closing this bug.  Please
reopen it or open a new one if you think it's happening again!

Thanks again
Pip