View Bug Activity | Format For Printing
The POSIX standard explicitly requires the function to return EAGAIN if the system lacks a resource to create the new thread. But when the function lacks memory, the returned error code is ENOMEM.
I don't think there is any case left where ENOMEM is returned. If yes, provide a test case.
Hello, If you set ulimit -s 512000 (thread_stack) on a 32bit system with >2GB RAM it is possible to get pthread_create to return ENOMEM. Strangely, ulimit -s unlimited or ulimit -s 8192 does not produce this ENOMEM result. Does pthread_create allocate a whole thread_stack size buffer for each thread if a ulimit -s is defined? See: http://bugs.mysql.com/bug.php?id=27487 OS error code 12: Cannot allocate memory InnoDB: Error: pthread_create returned 12 070329 14:54:41 mysqld ended This behavior has been experienced on: RHEL3 (2.4.21-37.ELsmp) and SuSE 10.1 (2.6.16.13-4-default) glibc-2.4-31
Oddly enough, it is more convenient to return the actual error code rather than generic EAGAIN (which would leave programmers blind ...). I would rather say to revise POSIX standard....
You haven't shown where in the current libc code there is a problem. Citing ancient libcs has no value at all. Here we are concern exclusively with current, upstream code.
Hi, Even pthread_create() returns the errno, but it doestnot sets the errno EAGAIN, instead it retains the ENOMEM. I have verified in glibc-2.7. Thats why the attached testcase results in.. $gcc -o test test.c -lpthread $./test pthread_create : Cannot allocate memory -> 12 Created 405 threads pthread_create : Cannot allocate memory -> 12 .......... .......... errno value set to 12 (ENOMEM) but needs to be EAGAIN. Ths attached patch fixes this issue. $./test pthread_create : Resource temporarily unavailable -> 11 Created 405 threads pthread_create : Resource temporarily unavailable -> 11 ................ ................ Thanks, Halesh
Created an attachment (id=2813) test case Test Case
Created an attachment (id=2814) patch to fix the issue
Don't ever report problem unless you can reproduce them with the latest glibc code from cvs. I've said this before, even in this bug, why the f*ck don't you read that first? There is no problem I can see in the current code.