Skip to content
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

Use _exit() in fork test to fix race #47

Merged
merged 1 commit into from
Nov 28, 2016
Merged

Conversation

SpamapS
Copy link
Member

@SpamapS SpamapS commented Nov 26, 2016

Been doing some analysis. So what happens is this:

  1. child forks, which ends up with the same socket for both child and parent.
    1-parent) parent calls waitpid to wait for child to exit
  2. child successfully echoes
  3. child calls exit() which calls some registered atexit handler which
    shuts down the shared connection
  4. parent wakes up, sees client was successful, tries to use the same
    connection socket which was just shut down.

I don't know how this test worked ever. But most likely there was a race
between the SIGCHLD and the exit handlers, and that may have been fixed
in recent libc's.

Closes #44

Been doing some analysis. So what happens is this:

  1) child forks, which ends up with the same socket for both child and parent.
  1-parent) parent calls waitpid to wait for child to exit
  2) child successfully echoes
  3) child calls exit() which calls some registered atexit handler which
     shuts down the shared connection
  4) parent wakes up, sees client was successful, tries to use the same
     connection socket which was just shut down.

I don't know how this test worked ever. But most likely there was a race
between the SIGCHLD and the exit handlers, and that may have been fixed
in recent libc's.

Closes #44
Copy link
Collaborator

@p-alik p-alik left a comment

Choose a reason for hiding this comment

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

test on ubuntu 16.04 ok

@SpamapS
Copy link
Member Author

SpamapS commented Nov 28, 2016

Thanks for testing! Travis agrees, and my tests on 14.04 and 16.04 have been successful. I'dlove to get a test up for centos/fedora too.

@SpamapS SpamapS merged commit 8277fb3 into gearman:master Nov 28, 2016
@esabol
Copy link
Member

esabol commented Nov 29, 2016

Modification tested on RHEL/CentOS 7.2... The test passes now! Cool beans.

esabol pushed a commit to esabol/gearmand that referenced this pull request Mar 23, 2017
Been doing some analysis. So what happens is this:

  1) child forks, which ends up with the same socket for both child and parent.
  1-parent) parent calls waitpid to wait for child to exit
  2) child successfully echoes
  3) child calls exit() which calls some registered atexit handler which
     shuts down the shared connection
  4) parent wakes up, sees client was successful, tries to use the same
     connection socket which was just shut down.

I don't know how this test worked ever. But most likely there was a race
between the SIGCHLD and the exit handlers, and that may have been fixed
in recent libc's.

Closes gearman#44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

client.fork.fork() test fails in some envorinments
3 participants