[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#980204: gdc: Resulting executables segfault on mipsel architecture (signal 11)



Excerpts from Matija Nalis's message of January 22, 2021 5:51 pm:
> On Fri, Jan 22, 2021 at 12:59:34PM +0100, Iain Buclaw wrote:
>> Also, are you linking to the static or shared libphobos library?
> 
> shared (default):
> 
> (mipsel-chroot):/tmp/w$ dpkg -l gdc | grep gdc
> ii  gdc            4:10.2.1-1   mipsel       D compiler (language version 2), based on the GCC backend
> 
> (mipsel-chroot):/tmp/w$ printf 'import std.stdio;\nvoid main()  { writeln("Hello, World!"); }\n' > hello.d ; gdc hello.d && ./a.out
> qemu: uncaught target signal 11 (Segmentation fault) - core dumped
> Segmentation fault
> 
> (mipsel-chroot):/tmp/w$ file a.out
> a.out: ELF 32-bit LSB pie executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked, interpreter /lib/ld.so.1, BuildID[sha1]=36c5576b94519b416c1996018760159ae925bc34, for GNU/Linux 3.2.0, not stripped
> 
> (mipsel-chroot):/tmp/w$ ldd a.out
>         libgphobos.so.1 => /lib/mipsel-linux-gnu/libgphobos.so.1 (0x7f1a3000)
>         libgcc_s.so.1 => /lib/mipsel-linux-gnu/libgcc_s.so.1 (0x7f16b000)
>         libc.so.6 => /lib/mipsel-linux-gnu/libc.so.6 (0x7efd1000)
>         libm.so.6 => /lib/mipsel-linux-gnu/libm.so.6 (0x7ef52000)
>         libpthread.so.0 => /lib/mipsel-linux-gnu/libpthread.so.0 (0x7ef21000)
>         libdl.so.2 => /lib/mipsel-linux-gnu/libdl.so.2 (0x7ef0d000)
>         libz.so.1 => /lib/mipsel-linux-gnu/libz.so.1 (0x7eee2000)
>         /lib/ld.so.1 (0x7ffc9000)
> 
> 
> But good point, when I try to link this "hello world" example statically, it
> throws warnings, but works!
> 
> (mipsel-chroot):/tmp/w$ printf 'import std.stdio;\nvoid main()  { writeln("Hello, World!"); }\n' > hello.d ; gdc -static hello.d && ./a.out
> /usr/bin/ld: /usr/lib/gcc/mipsel-linux-gnu/10/libgphobos.a(elf_shared.o): in function `_D3gcc8sections10elf_shared18pinLoadedLibrariesFNbNiZPv':
> /build/gcc-10-XdUysA/gcc-10-10.2.1/build/mipsel-linux-gnu/libphobos/libdruntime/../../../../src/libphobos/libdruntime/gcc/sections/elf_shared.d:250: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> /usr/bin/ld: /usr/lib/gcc/mipsel-linux-gnu/10/libgphobos.a(stdio.o): in function `_D3std5stdio11openNetworkFAyatZS3std5stdio4File':
> /build/gcc-10-XdUysA/gcc-10-10.2.1/build/mipsel-linux-gnu/libphobos/src/../../../../src/libphobos/src/std/stdio.d:5137: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> Hello, World!
> 

I've just checked the testsuite result, and the only failed tests are
those that use -shared-libphobos.

    FAIL: gdc.test/runnable/implicit.d -shared-libphobos   execution test
    FAIL: gdc.test/runnable/test31.d -shared-libphobos   execution test
    FAIL: gdc.test/runnable/testarray.d -shared-libphobos   execution test
    FAIL: gdc.test/runnable/Same.d -shared-libphobos   execution test
    FAIL: gdc.test/runnable/s2ir.d -shared-libphobos   execution test
    FAIL: gdc.test/runnable/test9309.d -shared-libphobos   execution test
    FAIL: gdc.test/runnable/test15.d -shared-libphobos   execution test
    etc...


>> Running the testsuite now, to see if there's any reported failures, but
>> none so far...
> 
> 
> However, when I try to build and run the more complex program Data_Generators/makedata/logmake.d
> from this version: http://snapshot.debian.org/archive/debian/20210115T023714Z/pool/main/i/ironseed/ironseed_0.3.6-4.dsc
> 
> it still fails with segfault on my qemu mipsel chroot, even when '-static' is added 
> (as it did on Debian buildd machine "eberlin.debian.org"):
> 
> (mipsel-chroot):/tmp/w/is/ironseed-0.3.6$ gdc -static -o Data_Generators/makedata/logmake Data_Generators/makedata/logmake.d Data_Generators/makedata/data.d && Data_Generators/makedata/logmake Data_Generators/makedata/logs.txt data/titles.dta data/log.dta
> /usr/bin/ld: /usr/lib/gcc/mipsel-linux-gnu/10/libgphobos.a(elf_shared.o): in function `_D3gcc8sections10elf_shared18pinLoadedLibrariesFNbNiZPv':
> /build/gcc-10-XdUysA/gcc-10-10.2.1/build/mipsel-linux-gnu/libphobos/libdruntime/../../../../src/libphobos/libdruntime/gcc/sections/elf_shared.d:250: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> /usr/bin/ld: /usr/lib/gcc/mipsel-linux-gnu/10/libgphobos.a(stdio.o): in function `_D3std5stdio11openNetworkFAyatZS3std5stdio4File':
> /build/gcc-10-XdUysA/gcc-10-10.2.1/build/mipsel-linux-gnu/libphobos/src/../../../../src/libphobos/src/std/stdio.d:5137: warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
> qemu: uncaught target signal 11 (Segmentation fault) - core dumped
> Segmentation fault
> 
> (mipsel-chroot):/tmp/w/is/ironseed-0.3.6$ file Data_Generators/makedata/logmake
> Data_Generators/makedata/logmake: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (GNU/Linux), statically linked, BuildID[sha1]=73dc65478408cfd9c17fba098575b7fe4078dbc7, for GNU/Linux 3.2.0, with debug_info, not stripped
> 
> 
> If unable to reproduce elsewhere, perhaps you could try to get
> "dget -x http://snapshot.debian.org/archive/debian/20210115T023714Z/pool/main/i/ironseed/ironseed_0.3.6-4.dsc";
> and build on your real MIPS hardware and see it if builds? 
> 
> (note that ironseed version 0.3.6-4 is required, as 0.3.6-5 and newer versions
> contain a workaround, so they do not try to use gdc on mipsel architecture
> as it is is not working)
> 

I can certainly give it a try after I look into why the shared library
is broken.

Iain


Reply to: