Subject: Re: bug#54814: 29.0.50; symbol visibility in modules may cause emacs crash in nativ-compilation emacs

From: [email-masked]
Date: Sat, 09 Apr 2022 20:30:51 +0200

Eli Zaretskii <[email-masked]> writes:

>> X-Spam-Status: No, score=-1 tagged_above=-999 required=6.2
>> 	tests=[ALL_TRUSTED=-1] autolearn=disabled
>> From: [email-masked]
>> Cc: Andrea Corallo <[email-masked]>,  [email-masked]
>> Date: Sat, 09 Apr 2022 18:18:10 +0200
>> 
>> Eli Zaretskii <[email-masked]> writes:
>> 
>> >> From: [email-masked]
>> >> Date: Sat, 09 Apr 2022 15:09:48 +0200
>> >> 
>> >> 
>> >> symbol visibility in modules may cause emacs crash in nativ-compilation
>> >> emacs
>> >
>> > Does it really have to do anything with native-compilation?  The fixes
>> > seem to be to compile the external modules with less visibility, but
>> > that doesn't affect Emacs, only the modules.
>> >
>> > Or am I missing something?
>> 
>> Well, I'm not really sure, but I have a couple of different builds of
>> emacs, and when I load the emacs-zmq precompiled binaries they crash my
>> main emacs, which has native-compilation, but not the other emacs I
>> tried this in. I also get the same result of crashing native emacs, when
>> using the packaged build proceedure of emacs-zmq. The hidden-visibility
>> branch seems to fix these problems.
>
> It's possible that Emacs with native-compilation somehow triggers the
> problem, but the proposed fixes are entirely in the modules, AFAICT.
>
>> Can I help pinpointing the issue somehow?
>
> A detailed explanation of why it crashes could help, I think.  All I
> saw are backtraces with no details, and no explanation what exactly
> caused the crash and how that was related to symbol visibility.

Well, I dont really know, but maybe having symbols in modules trigger a
crash in native compilation emacs? Wouldn't then removing the symbols
from the module remove the crash?

I attach a gdb bt below, but I really didnt do anything except load the
module, the crash happens immediately.

The crash does happen inside the module, but for me, only in native
compilation emacs.

17:11:45-joakim@tanaka:~/emacs-zmq$ gdb /home/joakim/build/myemacs/emacs/src/emacs
GNU gdb (GDB) Fedora 11.2-1.fc35
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/joakim/build/myemacs/emacs/src/emacs...
(gdb) run -q
Starting program: /mnt/fast/myemacs/emacs/src/emacs -q

This GDB supports auto-downloading debuginfo from the following URLs:
https://debuginfod.fedoraproject.org/ 
Enable debuginfod for this session? (y or [n]) n
Debuginfod has been disabled.
To make this setting permanent, add 'set debuginfod enabled off' to .gdbinit.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
[New Thread 0x7fffdc25a640 (LWP 260604)]
[New Thread 0x7fffdb70a640 (LWP 260608)]
Invalid cast.
warning: Probes-based dynamic linker interface failed.
Reverting to original interface.
[New Thread 0x7fffdac07640 (LWP 260609)]
[New Thread 0x7fffda07d640 (LWP 260610)]
[New Thread 0x7fffd9612640 (LWP 260611)]
[Thread 0x7fffd9612640 (LWP 260611) exited]
[New Thread 0x7fffd9612640 (LWP 260612)]
[New Thread 0x7fffd8c82640 (LWP 260613)]
[Thread 0x7fffd9612640 (LWP 260612) exited]
[New Thread 0x7fffd9612640 (LWP 260614)]
[New Thread 0x7fffd8c82640 (LWP 260615)]
[Thread 0x7fffd8c82640 (LWP 260613) exited]
[Thread 0x7fffd9612640 (LWP 260614) exited]
[Thread 0x7fffd8c82640 (LWP 260615) exited]

(emacs:260579): Gtk-CRITICAL **: 17:20:27.468: gtk_distribute_natural_allocation: assertion 'extra_space >= 0' failed

(emacs:260579): Gtk-CRITICAL **: 17:20:32.924: gtk_distribute_natural_allocation: assertion 'extra_space >= 0' failed
[Thread 0x7fffda07d640 (LWP 260610) exited]

(emacs:260579): Gtk-CRITICAL **: 17:21:07.507: gtk_distribute_natural_allocation: assertion 'extra_space >= 0' failed

(emacs:260579): Gtk-CRITICAL **: 17:21:17.041: gtk_distribute_natural_allocation: assertion 'extra_space >= 0' failed

Thread 1 "emacs" received signal SIGSEGV, Segmentation fault.
0x00007fffc3a627db in emacs_module_init (ert=<optimized out>) at emacs-zmq.c:286
286	    Qt = GLOBREF(INTERN("t"));
Missing separate debuginfos, use: dnf debuginfo-install GConf2-3.2.6-31.fc35.x86_64 ImageMagick-libs-6.9.12.37-1.fc35.x86_64 alsa-lib-1.2.6.1-3.fc35.x86_64 at-spi2-atk-2.38.0-3.fc35.x86_64 at-spi2-core-2.42.0-1.fc35.x86_64 atk-2.36.0-4.fc35.x86_64 bzip2-libs-1.0.8-9.fc35.x86_64 cairo-1.17.4-4.fc35.x86_64 cairo-gobject-1.17.4-4.fc35.x86_64 dbus-glib-0.112-2.fc35.x86_64 dbus-libs-1.12.22-1.fc35.x86_64 elfutils-libs-0.186-1.fc35.x86_64 fontconfig-2.13.94-5.fc35.x86_64 freetype-2.11.0-3.fc35.x86_64 fribidi-1.0.10-5.fc35.x86_64 gdk-pixbuf2-2.42.6-2.fc35.x86_64 giflib-5.2.1-8.fc35.x86_64 glib2-2.70.5-1.fc35.x86_64 glibc-2.34-29.fc35.x86_64 gmp-6.2.0-7.fc35.x86_64 gnutls-3.7.2-3.fc35.x86_64 gstreamer1-plugins-base-1.20.0-1.fc35.x86_64 gtk3-3.24.31-2.fc35.x86_64 gvfs-client-1.48.1-2.fc35.x86_64 harfbuzz-2.9.1-1.fc35.x86_64 jansson-2.13.1-3.fc35.x86_64 jbigkit-libs-2.1-22.fc35.x86_64 json-glib-1.6.6-1.fc35.x86_64 keyutils-libs-1.6.1-3.fc35.x86_64 krb5-libs-1.19.2-2.fc35.x86_64 lcms2-2.12-2.fc35.x86_64 libICE-1.0.10-7.fc35.x86_64 libSM-1.2.3-9.fc35.x86_64 libX11-1.7.3.1-1.fc35.x86_64 libXau-1.0.9-7.fc35.x86_64 libXcomposite-0.4.5-6.fc35.x86_64 libXcursor-1.2.0-6.fc35.x86_64 libXext-1.3.4-7.fc35.x86_64 libXpm-3.5.13-6.fc35.x86_64 libXrandr-1.5.2-7.fc35.x86_64 libXrender-0.9.10-15.fc35.x86_64 libXt-1.2.0-5.fc35.x86_64 libacl-2.3.1-2.fc35.x86_64 libcap-2.48-3.fc35.x86_64 libcom_err-1.46.3-1.fc35.x86_64 libepoxy-1.5.9-1.fc35.x86_64 libffi-3.1-29.fc35.x86_64 libgcc-11.2.1-9.fc35.x86_64 libgccjit-11.2.1-9.fc35.x86_64 libglvnd-egl-1.3.4-2.fc35.x86_64 libglvnd-glx-1.3.4-2.fc35.x86_64 libglvnd-opengl-1.3.4-2.fc35.x86_64 libgnomekbd-3.26.1-6.fc35.x86_64 libgomp-11.2.1-9.fc35.x86_64 libgpg-error-1.43-1.fc35.x86_64 libicu-69.1-2.fc35.x86_64 libjpeg-turbo-2.1.0-3.fc35.x86_64 liblqr-1-0.4.2-17.fc35.x86_64 libmanette-0.2.6-3.fc35.x86_64 libmpc-1.2.1-3.fc35.x86_64 libnghttp2-1.45.1-1.fc35.x86_64 libpng-1.6.37-11.fc35.x86_64 libraqm-0.7.2-1.fc35.x86_64 librsvg2-2.52.7-1.fc35.x86_64 libsecret-0.20.4-3.fc35.x86_64 libsoup-2.74.2-1.fc35.x86_64 libssh-0.9.6-1.fc35.x86_64 libstdc++-11.2.1-9.fc35.x86_64 libstemmer-0-17.585svn.fc35.x86_64 libthai-0.1.28-7.fc35.x86_64 libtiff-4.3.0-4.fc35.x86_64 libtool-ltdl-2.4.6-50.fc35.x86_64 libtracker-sparql-3.2.1-1.fc35.x86_64 libunwind-1.5.0-1.fc35.x86_64 libuuid-2.37.4-1.fc35.x86_64 libwayland-client-1.20.0-1.fc35.x86_64 libwayland-cursor-1.20.0-1.fc35.x86_64 libwayland-egl-1.20.0-1.fc35.x86_64 libwayland-server-1.20.0-1.fc35.x86_64 libwebp-1.2.2-1.fc35.x86_64 libwpe-1.10.1-2.fc35.x86_64 libxcb-1.13.1-8.fc35.x86_64 libxkbcommon-1.3.1-1.fc35.x86_64 libxml2-2.9.13-1.fc35.x86_64 libzstd-1.5.2-1.fc35.x86_64 lz4-libs-1.9.3-3.fc35.x86_64 mpfr-4.1.0-8.fc35.x86_64 openjpeg2-2.4.0-4.fc35.x86_64 openldap-2.4.59-3.fc35.x86_64 orc-0.4.31-5.fc35.x86_64 pixman-0.40.0-4.fc35.x86_64 sqlite-libs-3.36.0-3.fc35.x86_64 systemd-libs-249.9-1.fc35.x86_64 webkit2gtk3-2.34.6-1.fc35.x86_64 webkit2gtk3-jsc-2.34.6-1.fc35.x86_64 xapps-2.2.8-1.fc35.x86_64 xz-libs-5.2.5-7.fc35.x86_64 zlib-1.2.11-30.fc35.x86_64
(gdb) bt
#0  0x00007fffc3a627db in emacs_module_init (ert=<optimized out>) at emacs-zmq.c:286
#1  0x000000000063f304 in Fmodule_load (file=0xc86684) at emacs-module.c:1144
#2  0x000000000060b478 in eval_sub (form=<optimized out>) at eval.c:2382
#3  0x000000000060d7e7 in Feval (form=0x1038543, lexical=<optimized out>) at eval.c:2240
#4  0x00007fffea15a8d8 in F6576616c2d65787072657373696f6e_eval_expression_0 () at /mnt/fast/myemacs/emacs/src/../native-lisp/29.0.50-074789c9/preloaded/simple-34ebfc5b-c7860df7.eln
#5  0x0000000000607c73 in Ffuncall (nargs=nargs@entry=5, args=args@entry=0x7fffffffcfe8) at eval.c:2873
#6  0x000000000060378f in Ffuncall_interactively (nargs=5, args=0x7fffffffcfe8) at callint.c:260
#7  0x0000000000607c73 in Ffuncall (nargs=6, args=0x7fffffffcfe0) at eval.c:2873
#8  0x00000000006093f8 in Fapply (nargs=nargs@entry=3, args=args@entry=0x7fffffffd130) at eval.c:2550
#9  0x00000000006050b4 in Fcall_interactively (function=0x7fffe9cdd140 <text_data_reloc_imp_blob+6624>, record_flag=0x0, keys=0xc2bcc5) at callint.c:353
#10 0x00007fffea15e010 in F636f6d6d616e642d65786563757465_command_execute_0 () at /mnt/fast/myemacs/emacs/src/../native-lisp/29.0.50-074789c9/preloaded/simple-34ebfc5b-c7860df7.eln
#11 0x0000000000607c73 in Ffuncall (nargs=nargs@entry=2, args=args@entry=0x7fffffffd2d0) at eval.c:2873
#12 0x000000000058f9c6 in call1 (arg1=<optimized out>, fn=0x48c0) at /mnt/fast/myemacs/emacs/src/lisp.h:3216
#13 command_loop_1 () at keyboard.c:1514
#14 0x00000000006064e7 in internal_condition_case (bfun=bfun@entry=0x58f570 <command_loop_1>, handlers=handlers@entry=0x90, hfun=hfun@entry=0x5831d0 <cmd_error>) at eval.c:1450
#15 0x000000000057bb9a in command_loop_2 (handlers=handlers@entry=0x90) at keyboard.c:1142
#16 0x0000000000606441 in internal_catch (tag=tag@entry=0xf3c0, func=func@entry=0x57bb80 <command_loop_2>, arg=arg@entry=0x90) at eval.c:1180
#17 0x000000000057bb3f in command_loop () at keyboard.c:1120
#18 0x0000000000582d83 in recursive_edit_1 () at keyboard.c:729
#19 0x00000000005830fa in Frecursive_edit () at keyboard.c:812
#20 0x0000000000468cad in main (argc=2, argv=<optimized out>) at emacs.c:2447

-- 
Joakim Verona
[email-masked]