New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault in module destructor #1374

Closed
yazd opened this Issue Jan 13, 2016 · 4 comments

Comments

Projects
None yet
2 participants
@yazd
Contributor

yazd commented Jan 13, 2016

This code segfaults:

import std.parallelism;     /// import 1
import vibe.d;              /// import 2

void main()
{
    auto t = new TaskPool();
    t.isDaemon = true;
}

The segfault is in core.d:1510, static ~this(), st_threadsSignal.emit(); line.
If you change the import order, the segfault doesn't happen.
I realize that it is preferable to not mix vibe.d and std.parallelism, but the user of std.parallelism is a library that should work with and without vibe.d.

Running vibe.d 0.7.26 or vibe.d 0.7.27-alpha.3, dmd v2.069.2, linux x86-64.

@s-ludwig

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig Jan 29, 2016

Member

Looks like strange behavior on part of Druntime. What happens is that shared static ~this gets called before static ~this of the threads created by the task pool. The only "fix" that I see would be to detect this case and skip any per-thread cleanup in that case.

Member

s-ludwig commented Jan 29, 2016

Looks like strange behavior on part of Druntime. What happens is that shared static ~this gets called before static ~this of the threads created by the task pool. The only "fix" that I see would be to detect this case and skip any per-thread cleanup in that case.

@s-ludwig s-ludwig closed this in 951274b Jan 29, 2016

@yazd

This comment has been minimized.

Show comment
Hide comment
@yazd

yazd Jan 29, 2016

Contributor

If that is the case, it is a bug in druntime. The order is defined here: http://dlang.org/spec/module.html#staticorder

Shared static constructors on all modules are run before any static constructors.

and

Shared static destructors are executed after static destructors.

I'll try producing a minimal testcase and report the bug.

Contributor

yazd commented Jan 29, 2016

If that is the case, it is a bug in druntime. The order is defined here: http://dlang.org/spec/module.html#staticorder

Shared static constructors on all modules are run before any static constructors.

and

Shared static destructors are executed after static destructors.

I'll try producing a minimal testcase and report the bug.

@yazd

This comment has been minimized.

Show comment
Hide comment
@yazd
Contributor

yazd commented Jan 29, 2016

@s-ludwig

This comment has been minimized.

Show comment
Hide comment
@s-ludwig

s-ludwig Jan 29, 2016

Member

Ah nice, I looked for an explicit statement, but missed that part, so I wasn't sure.

Member

s-ludwig commented Jan 29, 2016

Ah nice, I looked for an explicit statement, but missed that part, so I wasn't sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment