Issue in _d_dso_registry on Linux when unloading DSO's

Jeremy DeHaan via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Apr 3 15:29:59 PDT 2017


I'm running into this issue when I compile DRuntime in debug. In 
sections_elf_shared.d, there's an assert on line 454 
(assert(pdso._tlsSize == _tlsRanges.back.length);). Because of 
this line, I get an assertion thrown, where the actual issue is 
that _tlsRanges is empty and thus has no "back". The GC has been 
finalized at this point in the program and can't actually 
allocate the assertion, so I end up with a segfault.

The whole bit of code looks like this:

assert(pdso._tlsSize == _tlsRanges.back.length);
_tlsRanges.popBack();
assert(pdso == _loadedDSOs.back);
_loadedDSOs.popBack();


Right now my "fix" looks like this:

if(!_tlsRanges.empty)
{
    assert(pdso._tlsSize == _tlsRanges.back.length);
    _tlsRanges.popBack();
}
assert(pdso == _loadedDSOs.back);
_loadedDSOs.popBack();


I have no idea if this is safe to do since I am not familiar with 
this code, but at least I don't have a segfault anymore. Can 
anyone help me figure out what is going on?


More information about the Digitalmars-d-learn mailing list