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

problem with signal handling and parallel GC on linux #2813

Merged
merged 1 commit into from Oct 6, 2019

Conversation

ikod
Copy link
Contributor

@ikod ikod commented Oct 5, 2019

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.

@dlang-bot
Copy link
Contributor

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 verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

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

Auto-close Bugzilla Severity Description
20256 regression problem with signal handling and parallel GC on linux

Testing this PR locally

If 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"

@dlang-bot dlang-bot added the Bug Fix Include reference to corresponding bugzilla issue label Oct 5, 2019
@@ -2874,6 +2874,18 @@ struct Gcx

void scanBackground() nothrow
{
version (posix)
Copy link
Member

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.

Copy link
Member

@rainers rainers left a 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.

version (Posix)
{
import core.sys.posix.signal;
// block all signals, scanThread inherits this mask.
Copy link
Member

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.

sigaddset(&m, SIGHUP);

auto x = new int[](10000);
for (int i=0; i<10000; i++)
Copy link
Member

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++)

Copy link
Member

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)

auto parent_pid = getpid();
auto child_pid = fork();
assert(child_pid >= 0);
if ( child_pid == 0 )
Copy link
Member

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)

@ikod
Copy link
Contributor Author

ikod commented Oct 6, 2019

Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Fix Include reference to corresponding bugzilla issue
Projects
None yet
4 participants