public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/98584] New: Many D tests FAIL with SIGBUS in read_encoded_value_with_base
@ 2021-01-07 16:27 ro at gcc dot gnu.org
  2021-04-20  0:28 ` [Bug d/98584] " cvs-commit at gcc dot gnu.org
  2021-04-20  0:40 ` ibuclaw at gdcproject dot org
  0 siblings, 2 replies; 3+ messages in thread
From: ro at gcc dot gnu.org @ 2021-01-07 16:27 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug d/98584] Many D tests FAIL with SIGBUS in read_encoded_value_with_base
  2021-01-07 16:27 [Bug d/98584] New: Many D tests FAIL with SIGBUS in read_encoded_value_with_base ro at gcc dot gnu.org
@ 2021-04-20  0:28 ` cvs-commit at gcc dot gnu.org
  2021-04-20  0:40 ` ibuclaw at gdcproject dot org
  1 sibling, 0 replies; 3+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-04-20  0:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98584

--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:

https://gcc.gnu.org/g:30b11d8d1be9c683f1517472c47a3cb69df02c4f

commit r11-8254-g30b11d8d1be9c683f1517472c47a3cb69df02c4f
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date:   Tue Apr 20 02:09:51 2021 +0200

    libphobos: Fix SIGBUS in read_encoded_value_with_base on sparc-sun-solaris
(PR98584)

    Instead of unsafe pointer dereferencing, use memcpy() to read encoded
    values from memory.  The function `read_encoded_value' has been updated
    to accept a ref parameter, this simplifies handling of the pointer to
    memory needing to be read.

    libphobos/ChangeLog:

            PR d/98584
            * libdruntime/gcc/deh.d (scanLSDA): Update calls to read_uleb128
and
            read_encoded_value.
            (actionTableLookup): Update calls to read_sleb128 and
            read_encoded_value_with_base.
            * libdruntime/gcc/unwind/pe.d (read_uleb128): Update signature.
            (read_sleb128): Update signature.
            (read_unaligned): New function.
            (read_encoded_value_with_base): Update signature.  Call
read_unaligned
            instead of unsafe pointer dereferencing.
            (read_encoded_value): Update signature.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug d/98584] Many D tests FAIL with SIGBUS in read_encoded_value_with_base
  2021-01-07 16:27 [Bug d/98584] New: Many D tests FAIL with SIGBUS in read_encoded_value_with_base ro at gcc dot gnu.org
  2021-04-20  0:28 ` [Bug d/98584] " cvs-commit at gcc dot gnu.org
@ 2021-04-20  0:40 ` ibuclaw at gdcproject dot org
  1 sibling, 0 replies; 3+ messages in thread
From: ibuclaw at gdcproject dot org @ 2021-04-20  0:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98584

--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
Running all D torture tests on sparc-sun-solaris2.11 with the RUNTESTFLAGS
--target_board=unix\{,-m64\}", I don't see any failures that arise in any f the
supported tests now.
---
                === gdc Summary for unix ===

# of expected passes            1520
# of unsupported tests          300

                === gdc Summary for unix/-m64 ===

# of expected passes            1520
# of unsupported tests          300

                === gdc Summary ===

# of expected passes            3040
# of unsupported tests          600
---

A variant of this patch can be backported to the gcc-10 branch as well if it is
useful.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-20  0:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07 16:27 [Bug d/98584] New: Many D tests FAIL with SIGBUS in read_encoded_value_with_base ro at gcc dot gnu.org
2021-04-20  0:28 ` [Bug d/98584] " cvs-commit at gcc dot gnu.org
2021-04-20  0:40 ` ibuclaw at gdcproject dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).