Closed eduardosm closed 1 year ago
I can reproduce this.
This is very odd. I have a lot of trouble justifying why this should even happen in the first place - how does builder-hex0
even work?
My first guess is that builder-hex0
does not have virtual memory, so the segfault is not trapped and tcc simply carries on. Although at that point tcc has entered the realm of undefined behavior, it is apparently able to produce a working executable.
I included a fix/workaround for this as part of https://github.com/fosslinux/live-bootstrap/pull/282, which consist of checking for null pointer, although I am not sure if it is legit for that pointer to be null.
I was testing some changes that would optionally enable building kernels (fiwix, linux) and related tools (lwext4, kexec) in chroot/bwrap builds, when tcc crashed while building lwext4.
Output
``` +> cd build +> untar --file ../src/lwext4-1.0.0-lb1.tar The extraction of ../src/lwext4-1.0.0-lb1.tar was successful +> cd lwext4-1.0.0-lb1 +> mkdir build_generic +> mkdir build_generic/include +> mkdir build_generic/include/generated +> catm build_generic/include/generated/ext4_config.h ../../config/ext4_config.h +> cd blockdev/linux +> tcc -m32 -march=i386 -std=c89 -I../../include -I../../build_generic/include -I../../../tcc/tcc-0.9.27/include -DVERSION="1.0" -c file_dev.c file_dev.c:71: warning: implicit declaration of function 'setbuf' +> cd ../../src +> alias cc=tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_balloc.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_bcache.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_bitmap.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_block_group.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_blockdev.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_crc32.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_debug.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_dir.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_dir_idx.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_extent.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_fs.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_hash.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_ialloc.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_inode.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_journal.c ext4_journal.c:1845: warning: assignment makes integer from pointer without a cast ext4_journal.c:1879: warning: assignment makes integer from pointer without a cast +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_mbr.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_mkfs.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_super.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_trans.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -c ext4_xattr.c +> catm make_fiwix_initrd.c ../../../files/make_fiwix_initrd.c +> tcc -m32 -march=i386 -std=c89 -I../include -I../build_generic/include -I../../tcc/tcc-0.9.27/include -DVERSION="1.0" -c make_fiwix_initrd.c +> tcc -m32 -o /usr/bin/make_fiwix_initrd ext4.o ext4_balloc.o ext4_bcache.o ext4_bitmap.o ext4_block_group.o ext4_blockdev.o ext4_crc32.o ext4_debug.o ext4_dir.o ext4_dir_idx.o ext4_extent.o ext4_fs.o ext4_hash.o ext4_ialloc.o ext4_inode.o ext4_journal.o ext4_mbr.o ext4_mkfs.o ext4_super.o ext4_trans.o ext4_xattr.o ../blockdev/linux/file_dev.o make_fiwix_initrd.o /usr/bin/tcc abnormal termination, signal number = 11 Subprocess error 11 ABORTING HARD Subprocess error 1 ABORTING HARD Subprocess error 1 ABORTING HARD Subprocess error ABORTING HARD ```The core dump as-is was not very useful, so I added the
-g
flag insysa/tcc-0.9.27/tcc-0.9.27.kaem
, so tcc 0.9.27 is built with debuginfo.After that, I got the following:
and
This is the function that crashes:
and the
for_each_elem
macro:It looks like the crash happens because
s1->got->reloc
is a NULL pointer.s1->got
ands1->got->reloc
are both pointers to aSection
That's all I figured out for now, I will look more into it later.