Subject: bug#33121: Crash during build with guile 2.2.4 on SPARC32

From: Frank Schaefer <[email-masked]>
Date: Mon, 22 Oct 2018 16:35:53 -0500

With guile 2.2.4 (and guile 2.2.3 as well), I get a nasty segfault during build:

/bin/sh: line 1:  4193 Broken pipe             cat alist.doc
array-handle.doc array-map.doc arrays.doc async.doc atomic.doc
backtrace.doc boolean.doc bitvectors.doc bytevectors.doc chars.doc
control.doc continuations.doc debug.doc deprecated.doc deprecation.doc
dynl.doc dynwind.doc eq.doc error.doc eval.doc evalext.doc expand.doc
extensions.doc fdes-finalizers.doc feature.doc filesys.doc fluids.doc
foreign.doc fports.doc gc-malloc.doc gc.doc gettext.doc
generalized-arrays.doc generalized-vectors.doc goops.doc gsubr.doc
guardians.doc hash.doc hashtab.doc hooks.doc i18n.doc init.doc
ioext.doc keywords.doc list.doc load.doc macros.doc mallocs.doc
memoize.doc modules.doc numbers.doc objprop.doc options.doc pairs.doc
ports.doc print.doc procprop.doc procs.doc promises.doc r6rs-ports.doc
random.doc rdelim.doc read.doc rw.doc scmsigs.doc script.doc
simpos.doc smob.doc sort.doc srcprop.doc srfi-1.doc srfi-4.doc
srfi-13.doc srfi-14.doc srfi-60.doc stackchk.doc stacks.doc stime.doc
strings.doc strorder.doc strports.doc struct.doc symbols.doc
syntax.doc threads.doc throw.doc trees.doc unicode.doc uniform.doc
values.doc variable.doc vectors.doc version.doc vports.doc
weak-set.doc weak-table.doc weak-vector.doc dynl.doc posix.doc
net_db.doc socket.doc regex-posix.doc
      4194 Segmentation fault      (core dumped) |
GUILE_AUTO_COMPILE=0 ../meta/build-env guild
snarf-check-and-output-texi > guile-procedures.texi
make[3]: *** [Makefile:4281: guile-procedures.texi] Error 1

Running a bare "./meta/build-env guile" with no other options gives me
a similar segfault.  Loading up the resulting core files in gdb reveal
that both crashes happen at the same point in libguile/vm-engine.c:

#0  0xf7c11cc8 in vm_regular_engine (thread=0x77e40, vp=0xe9f78,
registers=0xffe8cda0, resume=-138034004) at vm-engine.c:567
        proc = <optimized out>
        nlocals = 4157185728
        old_fp = <optimized out>
        new_fp = 0xf7c99ed0
        ip = <optimized out>
        sp = <optimized out>
        op = 6
        jump_table_ = {0xf7c11bac <vm_regular_engine+212>, 0xf7c11c20
<vm_regular_engine+328>, 0xf7c11cf8 <vm_regular_engine+544>,
0xf7c11d6c <vm_regular_engine+660>, 0xf7c11dd0
<vm_regular_engine+760>, 0xf7c11e18 <vm_regular_engine+832>,
          0xf7c11ee4 <vm_regular_engine+1036>, 0xf7c11f64
<vm_regular_engine+1164>, 0xf7c17f74 <vm_regular_engine+25756>,
0xf7c11f9c <vm_regular_engine+1220>, 0xf7c12004
<vm_regular_engine+1324>, 0xf7c1214c <vm_regular_engine+1652>,
          0xf7c17efc <vm_regular_engine+25636>, 0xf7c121e8
<vm_regular_engine+1808>, 0xf7c1224c <vm_regular_engine+1908>,
0xf7c12368 <vm_regular_engine+2192>, 0xf7c17d9c
<vm_regular_engine+25284>, 0xf7c1241c <vm_regular_engine+2372>,
          0xf7c12450 <vm_regular_engine+2424>, 0xf7c12494
<vm_regular_engine+2492>, 0xf7c124d8 <vm_regular_engine+2560>,
0xf7c1251c <vm_regular_engine+2628>, 0xf7c12554
<vm_regular_engine+2684>, 0xf7c1258c <vm_regular_engine+2740>,
0xf7c125c4 <vm_regular_engine+2796>,
          0xf7c12650 <vm_regular_engine+2936>, 0xf7c12690
<vm_regular_engine+3000>, 0xf7c126e8 <vm_regular_engine+3088>,
0xf7c12720 <vm_regular_engine+3144>, 0xf7c1274c
<vm_regular_engine+3188>, 0xf7c127e0 <vm_regular_engine+3336>,
0xf7c1281c <vm_regular_engine+3396>,
          0xf7c128c0 <vm_regular_engine+3560>, 0xf7c13368
<vm_regular_engine+6288>, 0xf7c132b0 <vm_regular_engine+6104>,
0xf7c1330c <vm_regular_engine+6196>, 0xf7c13144
<vm_regular_engine+5740>, 0xf7c131a0 <vm_regular_engine+5832>,
0xf7c131f8 <vm_regular_engine+5920>,
          0xf7c13254 <vm_regular_engine+6012>, 0xf7c12df0
<vm_regular_engine+4888>, 0xf7c12e48 <vm_regular_engine+4976>,
0xf7c12eb0 <vm_regular_engine+5080>, 0xf7c193ec
<vm_regular_engine+30996>, 0xf7c12f14 <vm_regular_engine+5180>,
0xf7c12f98 <vm_regular_engine+5312>,
          0xf7c13014 <vm_regular_engine+5436>, 0xf7c1308c
<vm_regular_engine+5556>, 0xf7c13104 <vm_regular_engine+5676>,
0xf7c12960 <vm_regular_engine+3720>, 0xf7c129a0
<vm_regular_engine+3784>, 0xf7c129e4 <vm_regular_engine+3852>,
0xf7c12a48 <vm_regular_engine+3952>,
          0xf7c12aa8 <vm_regular_engine+4048>, 0xf7c12afc
<vm_regular_engine+4132>, 0xf7c12bb4 <vm_regular_engine+4316>,
0xf7c12c00 <vm_regular_engine+4392>, 0xf7c12c4c
<vm_regular_engine+4468>, 0xf7c12c78 <vm_regular_engine+4512>,
0xf7c12ca4 <vm_regular_engine+4556>,
          0xf7c12cd0 <vm_regular_engine+4600>, 0xf7c12d0c
<vm_regular_engine+4660>, 0xf7c12d48 <vm_regular_engine+4720>,
0xf7c12d84 <vm_regular_engine+4780>, 0xf7c12dc0
<vm_regular_engine+4840>, 0xf7c1338c <vm_regular_engine+6324>,
0xf7c133f8 <vm_regular_engine+6432>,
          0xf7c13440 <vm_regular_engine+6504>, 0xf7c134ec
<vm_regular_engine+6676>, 0xf7c135c0 <vm_regular_engine+6888>,
0xf7c1363c <vm_regular_engine+7012>, 0xf7c13680
<vm_regular_engine+7080>, 0xf7c136a4 <vm_regular_engine+7116>,
0xf7c136ec <vm_regular_engine+7188>,
          0xf7c13718 <vm_regular_engine+7232>, 0xf7c137b4
<vm_regular_engine+7388>, 0xf7c13844 <vm_regular_engine+7532>,
0xf7c138a8 <vm_regular_engine+7632>, 0xf7c13958
<vm_regular_engine+7808>, 0xf7c1399c <vm_regular_engine+7876>,
0xf7c139dc <vm_regular_engine+7940>,
          0xf7c13a1c <vm_regular_engine+8004>, 0xf7c13a84
<vm_regular_engine+8108>, 0xf7c13ad4 <vm_regular_engine+8188>,
0xf7c13b28 <vm_regular_engine+8272>, 0xf7c13b94
<vm_regular_engine+8380>, 0xf7c13c00 <vm_regular_engine+8488>,
0xf7c13ca0 <vm_regular_engine+8648>,
          0xf7c13d04 <vm_regular_engine+8748>, 0xf7c13da4
<vm_regular_engine+8908>, 0xf7c13e04 <vm_regular_engine+9004>,
0xf7c13e50 <vm_regular_engine+9080>, 0xf7c13e9c
<vm_regular_engine+9156>, 0xf7c13ee8 <vm_regular_engine+9232>,
0xf7c13f34 <vm_regular_engine+9308>,
          0xf7c13f80 <vm_regular_engine+9384>, 0xf7c14014
<vm_regular_engine+9532>, 0xf7c14070 <vm_regular_engine+9624>,
0xf7c140cc <vm_regular_engine+9716>, 0xf7c1412c
<vm_regular_engine+9812>, 0xf7c14190 <vm_regular_engine+9912>,
0xf7c14cc4 <vm_regular_engine+12780>,
          0xf7c14d20 <vm_regular_engine+12872>, 0xf7c14da4
<vm_regular_engine+13004>, 0xf7c150c8 <vm_regular_engine+13808>,
0xf7c14c58 <vm_regular_engine+12672>, 0xf7c15074
<vm_regular_engine+13724>, 0xf7c14fa0 <vm_regular_engine+13512>,
          0xf7c14ff8 <vm_regular_engine+13600>, 0xf7c14e10
<vm_regular_engine+13112>, 0xf7c14e8c <vm_regular_engine+13236>,
0xf7c14ed4 <vm_regular_engine+13308>, 0xf7c14f3c
<vm_regular_engine+13412>, 0xf7c1423c <vm_regular_engine+10084>,
          0xf7c14298 <vm_regular_engine+10176>, 0xf7c142f8
<vm_regular_engine+10272>, 0xf7c14358 <vm_regular_engine+10368>,
0xf7c143f0 <vm_regular_engine+10520>, 0xf7c14494
<vm_regular_engine+10684>, 0xf7c14544 <vm_regular_engine+10860>,
          0xf7c14600 <vm_regular_engine+11048>, 0xf7c146bc
<vm_regular_engine+11236>, 0xf7c14780 <vm_regular_engine+11432>,
0xf7c14828 <vm_regular_engine+11600>, 0xf7c148d0
<vm_regular_engine+11768>, 0xf7c1498c <vm_regular_engine+11956>,
          0xf7c14a30 <vm_regular_engine+12120>, 0xf7c14ae0
<vm_regular_engine+12296>, 0xf7c14b94 <vm_regular_engine+12476>,
0xf7c15148 <vm_regular_engine+13936>, 0xf7c15d5c
<vm_regular_engine+17028>, 0xf7c15be4 <vm_regular_engine+16652>,
          0xf7c15cb8 <vm_regular_engine+16864>, 0xf7c159ac
<vm_regular_engine+16084>, 0xf7c15a4c <vm_regular_engine+16244>,
0xf7c15b04 <vm_regular_engine+16428>, 0xf7c15ba4
<vm_regular_engine+16588>, 0xf7c157ac <vm_regular_engine+15572>,
          0xf7c157f0 <vm_regular_engine+15640>, 0xf7c15834
<vm_regular_engine+15708>, 0xf7c15878 <vm_regular_engine+15776>,
0xf7c158bc <vm_regular_engine+15844>, 0xf7c15900
<vm_regular_engine+15912>, 0xf7c15924 <vm_regular_engine+15948>,
          0xf7c15968 <vm_regular_engine+16016>, 0xf7c1527c
<vm_regular_engine+14244>, 0xf7c152d8 <vm_regular_engine+14336>,
0xf7c15354 <vm_regular_engine+14460>, 0xf7c153d4
<vm_regular_engine+14588>, 0xf7c15458 <vm_regular_engine+14720>,
          0xf7c154ac <vm_regular_engine+14804>, 0xf7c15500
<vm_regular_engine+14888>, 0xf7c1556c <vm_regular_engine+14996>,
0xf7c155b4 <vm_regular_engine+15068>, 0xf7c155fc
<vm_regular_engine+15140>, 0xf7c15650 <vm_regular_engine+15224>,
          0xf7c15688 <vm_regular_engine+15280>, 0xf7c156c0
<vm_regular_engine+15336>, 0xf7c15704 <vm_regular_engine+15404>,
0xf7c15748 <vm_regular_engine+15472>, 0xf7c15780
<vm_regular_engine+15528>, 0xf7c15214 <vm_regular_engine+14140>,
          0xf7c16a9c <vm_regular_engine+20420>, 0xf7c169dc
<vm_regular_engine+20228>, 0xf7c16a3c <vm_regular_engine+20324>,
0xf7c167f0 <vm_regular_engine+19736>, 0xf7c1687c
<vm_regular_engine+19876>, 0xf7c16908 <vm_regular_engine+20016>,
          0xf7c16958 <vm_regular_engine+20096>, 0xf7c16424
<vm_regular_engine+18764>, 0xf7c164a4 <vm_regular_engine+18892>,
0xf7c1651c <vm_regular_engine+19012>, 0xf7c165a8
<vm_regular_engine+19152>, 0xf7c16634 <vm_regular_engine+19292>,
          0xf7c166c0 <vm_regular_engine+19432>, 0xf7c16744
<vm_regular_engine+19564>, 0xf7c167a0 <vm_regular_engine+19656>,
0xf7c15e24 <vm_regular_engine+17228>, 0xf7c15e84
<vm_regular_engine+17324>, 0xf7c15ef0 <vm_regular_engine+17432>,
          0xf7c15f4c <vm_regular_engine+17524>, 0xf7c15fa8
<vm_regular_engine+17616>, 0xf7c16010 <vm_regular_engine+17720>,
0xf7c1608c <vm_regular_engine+17844>, 0xf7c160d0
<vm_regular_engine+17912>, 0xf7c16108 <vm_regular_engine+17968>,
          0xf7c16140 <vm_regular_engine+18024>, 0xf7c1616c
<vm_regular_engine+18068>, 0xf7c161d0 <vm_regular_engine+18168>,
0xf7c16238 <vm_regular_engine+18272>, 0xf7c162a0
<vm_regular_engine+18376>, 0xf7c16308 <vm_regular_engine+18480>,
          0xf7c16370 <vm_regular_engine+18584>, 0xf7c17cfc
<vm_regular_engine+25124>, 0xf7c17e4c <vm_regular_engine+25460>,
0xf7c17e44 <vm_regular_engine+25452>, 0xf7c17e6c
<vm_regular_engine+25492>, 0xf7c17e64 <vm_regular_engine+25484>,
          0xf7c17e5c <vm_regular_engine+25476>, 0xf7c17e54
<vm_regular_engine+25468>...}
        jump_table = <optimized out>
#1  0xf7c19878 in scm_call_n (proc=0xfe558, argv=<optimized out>,
nargs=0) at vm.c:1257
        registers = {{__jmpbuf = {1321029988, 1321030260, 1184105584},
__mask_was_saved = 0, __saved_mask = {__val = {4155873416, 4157174424,
4293447156, 4293447152, 1, 0, 0, 14, 4157118508, 268435455,
4293447156, 4293447152, 4157169664, 1, 18, 78391725, 0, 0, 978032,
                0, 0, 712496, 4157186032, 1191, 4149848496,
4157117344, 4293447252, 4293447248, 0, 0, 0, 14}}}}
        resume = <optimized out>
        prev_cookie = 0xffe8d160
        ret = <optimized out>
        thread = 0x77e40
        vp = 0xe9f78
        return_fp = 0xf7c99f20
        call_fp = 0xf7c99f08
        call_nlocals = 1
        stack_reserve_words = 6
        i = <optimized out>
#2  0xf7ba9e34 in scm_primitive_load_path (args=<optimized out>) at load.c:1248

I dropped an fprintf(stderr,...) debug in that codepath to see what
address that code is attempting to unpack.  guile and guild both
consistently hit that codepath twice and crash on the second one; both
pointer values appear to point to reasonably sane addresses:

root:/usr/src/dist/guile-2.2.4/debian/tmp.build# ./meta/build-env guile
DEBUG FP_REF(0)==0xf7a83f38
DEBUG FP_REF(0)==0xf7a83ed0
Segmentation fault (core dumped)

FYI this is building for 32-bit SPARC, Linux 4.16.18, gcc-8.2.0,
glibc-2.28, gc-7.6.8, libatomic_ops-7.6.6 (gc and libatomic_ops both
pass all tests).  CFLAGS/CXXFLAGS is currently set to "-g -O2
-fdebug-prefix-map=/usr/src/dist/guile-2.2.4/debian/tmp.build=.
-Wformat -Werror=format-security -m32 -mcpu=v9 -mtune=v9
-fno-stack-protector" (I have also tried with -O1, with similar
results).  Building 64-bit guile on the same SPARC system (Sun
Enterprise T5240) exhibits no such crash.

Google dug up a few similar reports for 32-bit PowerPC, but apparently
nobody really took a close look at the time.  Is this maybe a problem
specific to 32-bit big-endian architectures?

I can supply the corefiles and config.log on request.  Be warned the
corefiles are about 260K compressed (122MB uncompressed).

--
Frank Schaefer
"If a server crashes in a server farm and no one pings it, does it
still cost four figures to fix?"