problem with signal handling and parallel GC on linux #2813
Conversation
Thanks for your pull request and interest in making D better, @ikod! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "stable + druntime#2813" |
src/gc/impl/conservative/gc.d
Outdated
@@ -2874,6 +2874,18 @@ struct Gcx | |||
|
|||
void scanBackground() nothrow | |||
{ | |||
version (posix) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's Posix
, not posix
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from nits, LGTM.
Please squash commits.
src/gc/impl/conservative/gc.d
Outdated
version (Posix) | ||
{ | ||
import core.sys.posix.signal; | ||
// block all signals, scanThread inherits this mask. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you mean scanBackground
here.
test/gc/sigmaskgc.d
Outdated
sigaddset(&m, SIGHUP); | ||
|
||
auto x = new int[](10000); | ||
for (int i=0; i<10000; i++) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code style nit: for (int i = 0; i < 10000; i++)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bonus for foreach (i; 0 .. 10000)
test/gc/sigmaskgc.d
Outdated
auto parent_pid = getpid(); | ||
auto child_pid = fork(); | ||
assert(child_pid >= 0); | ||
if ( child_pid == 0 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: if (child_pid == 0)
Thanks! |
Issue https://issues.dlang.org/show_bug.cgi?id=20256
Conservative GC scan threads do not block signals when created, which can lead to unexpected behaviour if developer have to block signals for whole process.
This PR fix issue by blocking all signals in conservative GC scanThreads.