https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98584
Bug ID: 98584 Summary: Many D tests FAIL with SIGBUS in read_encoded_value_with_base Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: d Assignee: ibuclaw at gdcproject dot org Reporter: ro at gcc dot gnu.org Target Milestone: --- Target: sparc-sun-solaris2.11 Inspired by the recent patch to enable libphobos with Solaris/x86 as, I tried the same on Solaris/SPARC (where libphobos is not yet enabled by default even with gas, but I've some success doing so anyway). However, when using as instead of gas, many tests FAIL with SIGBUS, e.g. FAIL: gdc.dg/torture/gdc17.d -O0 execution test Thread 2 received signal SIGBUS, Bus error. [Switching to Thread 1 (LWP 1)] gcc.unwind.pe.read_encoded_value_with_base(ubyte, uint, const(ubyte)**) (encoding=<optimized out>, base=0, p=0xffbfdb8c) at /vol/gcc/src/hg/master/local/libphobos/libdruntime/gcc/unwind/pe.d:200 200 result = cast(_Unwind_Internal_Ptr) *cast(int*)q; (gdb) where #0 gcc.unwind.pe.read_encoded_value_with_base(ubyte, uint, const(ubyte)**) (encoding=<optimized out>, base=0, p=0xffbfdb8c) at /vol/gcc/src/hg/master/local/libphobos/libdruntime/gcc/unwind/pe.d:200 #1 0x0005e258 in gcc.deh.scanLSDA(const(ubyte)*, ulong, int, gcc.unwind.generic._Unwind_Exception*, gcc.unwind.generic._Unwind_Context*, uint, out uint, out int) (lsda=0xcbd2c "\377", exceptionClass=<optimized out>, actions=1, unwindHeader=0xff040220, context=0xffbfdecc, cfa=4290766520, landingPad=@0xffbfdc0c: 0, handler=@0xffbfdc14: 0) at /vol/gcc/src/hg/master/local/libphobos/libdruntime/gcc/deh.d:634 #2 0x0005e508 in gcc.deh.__gdc_personality(int, ulong, gcc.unwind.generic._Unwind_Exception*, gcc.unwind.generic._Unwind_Context*) (actions=1, exceptionClass=5138137972268335104, unwindHeader=0xff040220, context=0xffbfdecc) at /vol/gcc/src/hg/master/local/libphobos/libdruntime/gcc/deh.d:917 #3 0xff07c4f8 in _Unwind_RaiseException (exc=0xff040220) at /builds2/ulhg/nightly_87/components/gcc10/gcc-10.2.0/libgcc/unwind.inc:118 #4 0x0005def4 in _d_throw (object=0xfef32000) at /vol/gcc/src/hg/master/local/libphobos/libdruntime/gcc/deh.d:509 #5 0x000656d0 in onAssertError (file=..., line=12) at /vol/gcc/src/hg/master/local/libphobos/libdruntime/core/exception.d:441 #6 0x00065c18 in _d_assert (file=..., line=12) at /vol/gcc/src/hg/master/local/libphobos/libdruntime/core/exception.d:641 #7 0x0005d1ac in gdc17.contractTest(immutable(char)[]) (path=...) at /vol/gcc/src/hg/master/local/gcc/testsuite/gdc.dg/torture/gdc17.d:12 #8 0x0005d2cc in gdc17.ModuleSaver.save(immutable(char)[]).__require() (this=0xffbfe728) at /vol/gcc/src/hg/master/local/gcc/testsuite/gdc.dg/torture/gdc17.d:21 #9 0x0005d330 in gdc17.ModuleWriter.save(immutable(char)[]) (this=0xfef31000, str=...) at /vol/gcc/src/hg/master/local/gcc/testsuite/gdc.dg/torture/gdc17.d:27 #10 0x0005d044 in D main () at /vol/gcc/src/hg/master/local/gcc/testsuite/gdc.dg/torture/gdc17.d:36 (gdb) p p $1 = (const ubyte **) 0xffbfdc04 (gdb) p/x p $2 = 0xffbfdc04 (gdb) p/x *p $3 = 0xcbd31 SPARC being a strict-alignment target, one cannot dereference an odd point as int *. #1 0x0005e258 in gcc.deh.scanLSDA(const(ubyte)*, ulong, int, gcc.unwind.generic._Unwind_Exception*, gcc.unwind.generic._Unwind_Context*, uint, out uint, out int) (lsda=0xcbd2c "\377", exceptionClass=<optimized out>, actions=1, unwindHeader=0xff040220, context=0xffbfdf44, cfa=4290766640, landingPad=@0xffbfdc84: 0, handler=@0xffbfdc8c: 0) at /vol/gcc/src/hg/master/local/libphobos/libdruntime/gcc/deh.d:634 634 auto CSStart = read_encoded_value(null, CSEncoding, &p); (gdb) p p $4 = (const ubyte *) 0xcbd31 "" Replacing gdc17.o from the gas build lets the test PASS. I have not yet determine where/how exactly the objects differ to cause this failure. However, comparing pe.d (read_encoded_value_with_base) with libgcc's unwind-pe.h, I find that the latter accounts for strict-alignment targets by using an union unaligned for the access instead of just casting.