Subject: Segfault in guile build on mac os 10.15 / xcode 11?

From: Dan Kegel <[email-masked]>
Date: Sat, 19 Oct 2019 16:17:58 -0700

I build guile and a few other things (including libgc, libffi,
libintl, libunistring, libgmp, and libltdl) locally using a
reproducible script.
I've been using it on linux and mac since the days of ubuntu 12.04 and
osx 10.8, and have kept it updated to work up through ubuntu 18.04 and
os 10.15 beta (as of 3 months ago).

Today I tried running it on final mac os 10.15 and more up to date xcode 11.
It explodes repeatably while building guile; the log shows

      4880 Segmentation fault: 11  | GUILE_AUTO_COMPILE=0
../meta/build-env guild snarf-check-and-output-texi >
guile-procedures.texi
make[3]: *** [guile-procedures.texi] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

This is with either guile-2.2.3 or 2.2.6.

~/Library/Logs/DiagnosticReports/guile_2019-10-19-154334_rbb-osx1015-2.crash
shows a backtrace:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libguile-2.2.1.dylib                0x0000000101e23e14
scm_i_symbol_chars + 4 (strings.c:818)
1   libguile-2.2.1.dylib                0x0000000101e2a1da
scm_i_struct_inherit_vtable_magic + 42 (struct.c:204)
2   libguile-2.2.1.dylib                0x0000000101e2a7f9
scm_c_make_structv + 329 (struct.c:507)
3   libguile-2.2.1.dylib                0x0000000101e2ab7c
scm_c_make_struct + 236
4   libguile-2.2.1.dylib                0x0000000101e2bc9b
scm_init_struct + 219 (struct.c:1088)
5   libguile-2.2.1.dylib                0x0000000101dc3a71
scm_i_init_guile + 129 (init.c:413)
6   libguile-2.2.1.dylib                0x0000000101e2cf08
scm_i_init_thread_for_guile + 120 (threads.c:590)
7   libguile-2.2.1.dylib                0x0000000101e2f1b9 with_guile
+ 25 (threads.c:654)
8   libgc.1.dylib                       0x0000000101f441bb
GC_call_with_stack_base + 27
9   libguile-2.2.1.dylib                0x0000000101e2cf6b
scm_with_guile + 43 (threads.c:710)
10  libguile-2.2.1.dylib                0x0000000101dc3995
scm_boot_guile + 69 (init.c:329)
11  guile                               0x0000000101d88e9f main + 191
(guile.c:102)
12  libdyld.dylib                       0x00007fff64dd6405 start + 1
...

 812 const char *
 813 scm_i_symbol_chars (SCM sym)
 814 {
 815   SCM buf;
 816
 817   buf = SYMBOL_STRINGBUF (sym);
 818   if (!STRINGBUF_WIDE (buf))
 819     return (const char *) STRINGBUF_CHARS (buf);

I tried to get the OS to generate a full core dump, but apple's
instructions to make sure /cores is
writable fail on os 10.15.  Maybe if I turn off SIP, but I can't do
that until Monday.

I can reproduce the problem by running just

GUILE_AUTO_COMPILE=0 meta/build-env guild

in the top level of the source tree, but I haven't figured out how to
reproduce it in lldb yet.

I tried unwinding all the wrappers, e.g.

tail +5 meta/guild > guild.txt
# do what meta-env would do:
export GUILE=/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/libguile/guile
export GUILE_LOAD_COMPILED_PATH=/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/module:/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/bootstrap:/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/prebuilt/64-bit-little-endian:/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/guile-readline
export GUILE_LOAD_PATH=/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/module:/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/guile-readline
export GUILE_SYSTEM_COMPILED_PATH=
export GUILE_SYSTEM_EXTENSIONS_PATH=
export GUILE_SYSTEM_PATH=
export LTDL_LIBRARY_PATH=/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/libguile:/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/guile-readline
export PATH=/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/meta:/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/libguile:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Library/Apple/bin:/opt/X11/bin:/Users/buildbot/Library/Python/3.7/bin
export PKG_CONFIG_PATH=/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/meta
export XDG_CACHE_HOME=/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/cache
export GUILE_AUTO_COMPILE=0
$GUILE  -e '(@@ (guild) main)' guild.txt

That still crashes, and so does replacing the last line with

/Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/libguile/.libs/guile
-e '(@@ (guild) main)' guild.txt

but alas replacing the last line with

lldb /Users/buildbot/src/yobuild/recipes/guile/btmp/guile-2.2.6/libguile/.libs/guile
-- -e '(@@ (guild) main)' guild.txt

and running it just exits with status -1.