This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] Fix tst-cancel17/tst-cancelx17, which sometimes segfaults while exiting.
- From: Stefan Liebler <stli at linux dot vnet dot ibm dot com>
- To: libc-alpha at sourceware dot org
- Date: Tue, 17 May 2016 10:50:35 +0200
- Subject: Re: [PATCH] Fix tst-cancel17/tst-cancelx17, which sometimes segfaults while exiting.
- Authentication-results: sourceware.org; auth=none
- References: <nhefc9$v3q$1 at ger dot gmane dot org> <85905d7a-0d26-f858-f3d0-0b4bf38b512a at redhat dot com>
On 05/17/2016 09:18 AM, Florian Weimer wrote:
On 05/17/2016 08:57 AM, Stefan Liebler wrote:
* nptl/tst-cancel17.c (do_test): Wait for finishing aio_read(&a).
Nice analysis. Looks good to me.
diff --git a/nptl/tst-cancel17.c b/nptl/tst-cancel17.c
index fb89292..9ff4e27 100644
@@ -333,6 +333,22 @@ do_test (void)
puts ("early cancellation succeeded");
+ if (ap == &a2)
+ /* The aio_read(&a) was not canceled, because the read request was
+ already in progress. In the meanwhile aio_write(ap) wrote something
+ to the pipe and the read request either has already been
+ is able to read the requested byte.
+ Wait for the read request before returning from this function,
+ the return value and error code from the read syscall will be
+ to the struct aiocb a, which lays on the stack of this function.
+ Otherwise the stack from subsequent function calls - e.g.
+ will be corrupted, which can lead to undefined behaviour like a
+ segmentation fault. */
I think it should be âwhich *lies* on the stackâ (the intransitive
variant), and a comma before âbecauseâ is frowned upon in some circles.
Committed with your comments.