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

context1.c - better end-of-stream, signal handling #39

Merged
merged 1 commit into from
Sep 18, 2016

Conversation

gstrauss
Copy link
Collaborator

Addresses "slave write failed: Broken pipe; aborting"

There are two processes that are alternating reading and writing
a sequence number of sizeof(unsigned long) size, which is 4 bytes
on 32-bit ILP32 ABI and 8 bytes on 64-bit LP64 ABI. The read/write
passing of incrementing sequence number occurs in infinite loop
until an alarm signals each process. There is a race condition
where a signal delivered to one process might close the pipes while
the second process was still attempting to read or write from the
pipes, and before the second process was interrupted with SIGALRM.

This patch fixes the race condition that occurs at the end of the
test run, after the first SIGALRM is delivered.

This patch does not address the paranoid possibility that read() or
write() of 4 or 8 bytes might theoretically be a partial read() or
write(), but that is extremely unlikely except in the case of a signal
being delivered, and the only signal expected is SIGALRM, and the
processing of SIGALRM by report() function does not return. (This
patch adds code to ignore SIGPIPE, so SIGALRM is the only expected
signal.)

github: fixes #1

Addresses "slave write failed: Broken pipe; aborting"

There are two processes that are alternating reading and writing
a sequence number of sizeof(unsigned long) size, which is 4 bytes
on 32-bit ILP32 ABI and 8 bytes on 64-bit LP64 ABI.  The read/write
passing of incrementing sequence number occurs in infinite loop
until an alarm signals each process.  There is a race condition
where a signal delivered to one process might close the pipes while
the second process was still attempting to read or write from the
pipes, and before the second process was interrupted with SIGALRM.

This patch fixes the race condition that occurs at the end of the
test run, after the first SIGALRM is delivered.

This patch does not address the paranoid possibility that read() or
write() of 4 or 8 bytes might theoretically be a partial read() or
write(), but that is extremely unlikely except in the case of a signal
being delivered, and the only signal expected is SIGALRM, and the
processing of SIGALRM by report() function does not return.  (This
patch adds code to ignore SIGPIPE, so SIGALRM is the only expected
signal.)

github: fixes kdlucas#1
@kdlucas kdlucas merged commit 088ceb2 into kdlucas:master Sep 18, 2016
@gstrauss gstrauss deleted the context1-fix-end-of-test branch September 18, 2016 04:49
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.

Pipe-based Context Switching - slave write failed: Broken pipe
2 participants