This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Patch] Fix return value in pthread_create


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


pthread_create is supposed to return EAGAIN if there are insufficient
resources to create the new thread.

This problem was partially fixed in 0f7e0ee5, BZ 5245.  However it
missed the case where there's a failure allocating the thread's stack.

2011-12-14  Jeff Law  <law@redhat.com>

	* pthread_create.c (pthread_create_2_1): Translate ENOMEM to
	EAGAIN.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJO6Qw4AAoJEBRtltQi2kC7+DwH/i/xadL/BYexBpPolZ8i2LCP
v+GPMP4lc2FN5sZTvERRDU9eDiUbmDrWH94jw/NESXoJLCQK0rA0DbWOYLopLTaJ
Kwai3K4QFX+SJwYL7it+o/lt7vKl6a89kMcr3iR8WM3MNsmIrzMxxLxI9/EJcrbn
6pc3kDZL7fm1F7RBDnOBC31tF0ptObyL21GMPmMOpfYIXSa+9E32yC/TQYfQtNA4
hFkPvguq6KuFnIeC2HYvuecI11vbbR623YUz6zLoUV1eTMibxnZg2eH+A60UkYWQ
+/6ahki1/CXI8T76jCWe0veReS2cDChPQ0dINLGfcmPorZcv7AqFHctKZKgedfQ=
=pM4/
-----END PGP SIGNATURE-----
--- a/nptl/pthread_create.c	2011-12-13 11:41:37.000000000 -0700
+++ b/nptl/pthread_create.c	2011-12-14 10:03:13.000000000 -0700
@@ -440,8 +440,9 @@
   int err = ALLOCATE_STACK (iattr, &pd);
   if (__builtin_expect (err != 0, 0))
     /* Something went wrong.  Maybe a parameter of the attributes is
-       invalid or we could not allocate memory.  */
-    return err;
+       invalid or we could not allocate memory.  Note we have to
+       translate error codes.  */
+    return err == ENOMEM ? EAGAIN : err;
 
 
   /* Initialize the TCB.  All initializations with zero should be

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]