diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | nptl/tst-cancel20.c | 15 | ||||
-rw-r--r-- | nptl/tst-cancel21.c | 15 |
3 files changed, 24 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog index 9da4f3c75b..b768cd5ba4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2015-12-02 Adhemerval Zanella <adhemerval.zanella@linaro.org> + + * nptl/tst-cancel20.c (do_one_test): Move the pipe closing after + pthread_join. + * nptl/tst-cancel21.c (tf): Likewise. + 2015-12-01 H.J. Lu <hongjiu.lu@intel.com> [BZ #19313] diff --git a/nptl/tst-cancel20.c b/nptl/tst-cancel20.c index 51b558e98d..91452fb97a 100644 --- a/nptl/tst-cancel20.c +++ b/nptl/tst-cancel20.c @@ -145,12 +145,6 @@ do_one_test (void) return 1; } - /* This will cause the read in the child to return. */ - close (fd[0]); - close (fd[1]); - close (fd[2]); - close (fd[3]); - void *ret; if (pthread_join (th, &ret) != 0) { @@ -170,6 +164,15 @@ do_one_test (void) return 1; } + /* The pipe closing must be issued after the cancellation handling to avoid + a race condition where the cancellation runs after both pipe ends are + closed. In this case the read syscall returns EOF and the cancellation + must not act. */ + close (fd[0]); + close (fd[1]); + close (fd[2]); + close (fd[3]); + return 0; } diff --git a/nptl/tst-cancel21.c b/nptl/tst-cancel21.c index b54f236b03..d082776059 100644 --- a/nptl/tst-cancel21.c +++ b/nptl/tst-cancel21.c @@ -123,12 +123,6 @@ tf (void *arg) exit (1); } - /* This will cause the read in the initial thread to return. */ - close (fd[0]); - close (fd[1]); - close (fd[2]); - close (fd[3]); - void *ret; if (pthread_join (th, &ret) != 0) { @@ -154,6 +148,15 @@ tf (void *arg) exit (1); } + /* The pipe closing must be issued after the cancellation handling to avoid + a race condition where the cancellation runs after both pipe ends are + closed. In this case the read syscall returns EOF and the cancellation + must not act. */ + close (fd[0]); + close (fd[1]); + close (fd[2]); + close (fd[3]); + exit (0); } |