Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Conversation

MartinNowak
Copy link
Member

depends on #587 and #589

- When calling rt_init/rt_term from ELF's .ctors/.dtors section
  atexit runs before rt_term, which causes a crash because the
  thread locks are already destroyed.
- runModuleUnitTests is no longer called from rt_init
  but needs to be called separatly
add explicit thread_term call to replace atexit
@WalterBright
Copy link
Member

You should say that this supercedes #583

But there is a synchronization problem with it. When an exception is thrown, DSO.opAppy() gets called, and _static_dso[] is walked. But if, during this walk, another thread loads/unloads a library, then the former version of _static_dso[] points to garbage, and it crashes.

This is also why the 'nothrow' was added to deh_win64_posix.d.

unregisterGCRanges(pdso);
assert(pdso._tlsSize == _tlsRanges.back.length);
_tlsRanges.popBack();
assert(pdso == _static_dsos.back); // static DSOs are unloaded in reverse order
_static_dsos.popBack();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if dll A is dynamically loaded, then dll B is dynamically loaded, then dll A is unloaded? The assert in line 194 will fail. The code in #583 deals with that case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm about to prepare another pull for dynamic loading so the issue doesn't apply here.

@MartinNowak
Copy link
Member Author

You should say that this supercedes #583

But there is a synchronization problem with it. When an exception is thrown, DSO.opAppy() gets called, and _static_dso[] is walked. But if, during this walk, another thread loads/unloads a library, then the former version of _static_dso[] points to garbage, and it crashes.

This is also why the 'nothrow' was added to deh_win64_posix.d.

Interesting problem, didn't knew about this. But again it will only apply to dynamic loading which isn't part of this pull request.

@WalterBright
Copy link
Member

I don't see the point of this as it breaks #583 but doesn't support dynamic loading at all. I'd prefer that #583 was pulled and then another pull was done to address its shortcomings.

@MartinNowak MartinNowak mentioned this pull request Aug 27, 2013
@dnadlinger
Copy link
Contributor

As far as I can see, #583 has a serious issue w.r.t. only picking up symbols from the libphobos so (see Martin's comment), doesn't it?

WalterBright added a commit that referenced this pull request Sep 1, 2013
perform runtime and module initialization when loading DSOs
@WalterBright WalterBright merged commit 99496ed into dlang:master Sep 1, 2013
@MartinNowak
Copy link
Member Author

This caused a regression Issue 10976 and here is the fix #600.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants