]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - nptl/tst-cancel17.c
Add per-thread cache to malloc
[thirdparty/glibc.git] / nptl / tst-cancel17.c
index 04d05d1b7bd5074daaa5a5196692f029854503be..33204978e512d235597afcad10322917c77f51f6 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003-2015 Free Software Foundation, Inc.
+/* Copyright (C) 2003-2017 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
 
@@ -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 finished or
+        is able to read the requested byte.
+        Wait for the read request before returning from this function because
+        the return value and error code from the read syscall will be written
+        to the struct aiocb a, which lies on the stack of this function.
+        Otherwise the stack from subsequent function calls - e.g. _dl_fini -
+        will be corrupted, which can lead to undefined behaviour like a
+        segmentation fault.  */
+      const struct aiocb *l[1] = { &a };
+      TEMP_FAILURE_RETRY (aio_suspend(l, 1, NULL));
+    }
+
   return 0;
 }