This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug d/88150] Use sections_elf_shared.d on Solaris


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

--- Comment #6 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot Uni-Bielefeld.DE> ---
The revised patch (still with loads of hacks) allowed the vast majority
of Solaris 11.4/x86 gdc tests to PASS, both 32 and 64-bit:

                === gdc Summary ===

# of expected passes            61178
# of unexpected failures        36
# of unresolved testcases       12

The results are identical on Solaris 11.3/x86 with the patches for PR
d/87864 (which provides minfo bracketing if ld doesn't) and
https://gcc.gnu.org/ml/gcc-patches/2018-11/msg02248.html (which links
with -lsocket -lnsl if need be).

Solaris/SPARC is still another issue: I'll report my findings
separately.

Here are the changes from the previous version of the patch:

* Solaris ld doesn't provide __bss_start (and no exact equivalent).
  Since __bss_start is declared weak in rt/bss_section.c, this won't get
  noticed at link time, but manifests itself as a SEGV caused by an
  assertion failure:

Thread 2 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
gc_malloc (sz=40, ba=0, 
    ti=0xff051250 <ClassInfo for core.exception.AssertError>)
    at /vol/gcc/src/hg/trunk/local/libphobos/libdruntime/gc/proxy.d:117
117             return instance.malloc(sz, ba, ti);
(gdb) where
#0  gc_malloc (sz=40, ba=0, 
    ti=0xff051250 <ClassInfo for core.exception.AssertError>)
    at /vol/gcc/src/hg/trunk/local/libphobos/libdruntime/gc/proxy.d:117
#1  0xfefdd018 in _d_newclass (
    ci=0xff051250 <ClassInfo for core.exception.AssertError>)
    at /vol/gcc/src/hg/trunk/local/libphobos/libdruntime/rt/lifetime.d:96
#2  0xfefaa5cc in onAssertError (file=..., line=918)
    at /vol/gcc/src/hg/trunk/local/libphobos/libdruntime/core/exception.d:441
#3  0xfefaaedc in _d_assert (file=..., line=918)
    at /vol/gcc/src/hg/trunk/local/libphobos/libdruntime/core/exception.d:641
#4  0xfefe9ff4 in rt.sections_elf_shared.getCopyRelocSection() ()
    at
/vol/gcc/src/hg/trunk/local/libphobos/libdruntime/rt/sections_elf_shared.d:918
#5  0xfefebfbc in _d_dso_registry (data=0xffbfe288)
    at
/vol/gcc/src/hg/trunk/local/libphobos/libdruntime/rt/sections_elf_shared.d:402
#6  0xfef968b8 in gdc.dso_ctor () at <no_file>:1
#7  gdc.dso_ctor ()
    at /vol/gcc/src/hg/trunk/local/libphobos/libdruntime/core/atomic.d:1
#8  global constructors keyed to 4core6atomic ()
    at /vol/gcc/src/hg/trunk/local/libphobos/libdruntime/core/atomic.d:1
#9  0xff1a0ccc in call_array () from /usr/lib/ld.so.1
#10 0xff1a0e4c in call_init () from /usr/lib/ld.so.1
#11 0xff1a015c in setup () from /usr/lib/ld.so.1
#12 0xff1b1d44 in _setup () from /usr/lib/ld.so.1
#13 0xff192738 in _rt_boot () from /usr/lib/ld.so.1
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

  probably an assertion failure for

    findDSOInfoForAddr(bss_start, &info) || assert(0);

  since bss_start will be 0 if __bss_start doesn't exist.  I've hacked
  around this by using _edata instead, which is close, but doesn't
  account for the alignment of the .bss section.

* Solaris currently lacks dlpi_tls_modid.  The field will probably be
  added to struct dl_phdr_info in Solaris 11.5 and perhaps backported to
  11.4.  I may be able to use the hack (making use of undocumented libc
  internals) from src/rt/sections_ldc.d in the ldc-developers druntime
  repo in on github if this turns out to work and be stable across
  Solaris 10 to 11.3.

  For now, I'm cheating by always setting _tlsMod to 0 on Solaris and
  disabling the corresponding assertions.

* This allowed the gdc execution tests with -static-libphobos to PASS,
  but the -shared-libphobos tests would still FAIL, again with a SEGV

Thread 2 received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1 (LWP 1)]
0xfe5a9559 in gc_malloc (sz=40, ba=0, 
    ti=0xfe5eb180 <ClassInfo for core.exception.AssertError>)
    at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/gc/proxy.d:117
117             return instance.malloc(sz, ba, ti);
(gdb) where
#0  0xfe5a9559 in gc_malloc (sz=40, ba=0, 
    ti=0xfe5eb180 <ClassInfo for core.exception.AssertError>)
    at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/gc/proxy.d:117
#1  0xfe553478 in core.memory.GC.malloc(uint, uint, const(TypeInfo)) (sz=40, 
    ba=0, ti=0xfe5eb180 <ClassInfo for core.exception.AssertError>)
    at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/core/memory.d:380
#2  0xfe576a04 in _d_newclass (
    ci=0xfe5eb180 <ClassInfo for core.exception.AssertError>)
    at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/lifetime.d:96
#3  0xfe551994 in onAssertError (file=..., line=657)
    at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/core/exception.d:441
#4  0xfe551d12 in _d_assert (file=..., line=657)
    at /vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/core/exception.d:641
#5  0xfe583579 in
rt.sections_elf_shared.setDSOForHandle(rt.sections_elf_shared.DSO*, void*)
(pdso=0x8062420, handle=0xfe6d27a8)
    at
/vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/sections_elf_shared.d:657
#6  0xfe5822f0 in _d_dso_registry (data=0xfeffd3d4)
    at
/vol/gcc/src/hg/trunk/solaris/libphobos/libdruntime/rt/sections_elf_shared.d:409
#7  0xfe0c3540 in gdc.dso_ctor () at <no_file>:1
#8  0xfe0c34b2 in global constructors keyed to 3etc1c4curl ()
    at /vol/gcc/src/hg/trunk/solaris/libphobos/src/etc/c/curl.d:1
#9  0xfe6b05cb in call_array () from /usr/lib/ld.so.1
#10 0xfe6b0777 in call_init () from /usr/lib/ld.so.1
#11 0xfe6af53c in setup () from /usr/lib/ld.so.1
#12 0xfe6c1c80 in _setup () from /usr/lib/ld.so.1
#13 0xfe6a1e7f in _rt_boot () from /usr/lib/ld.so.1
#14 0xfeffd8e4 in ?? ()
#15 0xfeffda62 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)

  caused by an assertion failure here:

   void setDSOForHandle(DSO* pdso, void* handle) nothrow @nogc
    {
        !pthread_mutex_lock(&_handleToDSOMutex) || assert(0);
        assert(handle !in _handleToDSO);

  Both the first and second times through _d_dso_registry (first for
  libgdruntime.so.76.0.3, then for libgphobos.so.76.0.3), I'd get the
  same dlopen handle, leading to the assertion failure above.

  However, I wonder how this can work at all: going through
  handleForAddr and then handleForName

    void* handleForName(const char* name) nothrow @nogc
    {
        auto handle = .dlopen(name, RTLD_NOLOAD | RTLD_LAZY);
        if (handle !is null) .dlclose(handle); // drop reference count
        return handle;
    }

  how can one expect that the handle returned for a different DSO the
  next time through isn't the same after it has first been dlclose'd?  I
  must be missing something here...

  With the dlclose disabled on Solaris to keep the handle valid on
  return from handleForName, I'm getting the test results cited above,
  perhaps an indication that this is not totally wrong ;-)

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]