Bug 114515

Summary: pthread_join() error
Product: Red Hat Enterprise Linux 2.1 Reporter: Craig MacPherson <cmacpher>
Component: glibcAssignee: Jakub Jelinek <jakub>
Status: CLOSED WORKSFORME QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 2.1CC: drepper, eparis, fweimer, riel
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-09-28 10:03:33 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
strace as requested.
none
strace output as requested - first file was std io none

Description Craig MacPherson 2004-01-29 00:02:38 UTC
We're having a problem on Red Hat AS 2.1 - we're getting pthread_join
() error  
after 15 threads.  This is really simple test to reproduce problem.

Comment 1 Craig MacPherson 2004-01-29 00:04:04 UTC
 
Contact: 
cmacpher  or  (403) 296-4329. 
 
When I run the program code below the output is.... 
pthread_create() 0 
pthread_create() 1 
pthread_create() 2 
pthread_create() 3 
pthread_create() 4 
pthread_create() 5 
pthread_create() 6 
pthread_create() 7 
pthread_create() 8 
pthread_create() 9 
pthread_create() 10 
pthread_create() 11 
pthread_create() 12 
pthread_create() 13 
pthread_create() 14 
pthread_create() error=Interrupted system call 
pthread_create() error=Interrupted system call 
pthread_create() error=Interrupted system call 
pthread_create() error=Interrupted system call 
pthread_create() error=Interrupted system call 
<snip> same error message 85 more times... 
pthread_create() 0 
pthread_create() 1 
pthread_create() 2 
pthread_create() 3 
pthread_create() 4 
pthread_create() 5 
pthread_create() 6 
pthread_create() 7 
pthread_create() 8 
pthread_create() 9 
pthread_create() 10 
pthread_create() 11 
pthread_create() 12 
pthread_create() 13 
pthread_create() 14 
pthread_create() error=Interrupted system call 
pthread_create() error=Interrupted system call 
pthread_create() error=Interrupted system call 
pthread_create() error=Interrupted system call 
pthread_create() error=Interrupted system call 
pthread_create() error=Interrupted system call 
pthread_create() error=Interrupted system call 
pthread_create() error=Interrupted system call 
pthread_create() error=Interrupted system call 
<snip> same error message 85 more times. 
 


Description of problem:
Cut and past the code below into a file thread100.c 
compile/link with command "cc -o thread100 -lpthread thread100.c" and 
run it  
as ./thread100 
 
------------- x ----------- 
#include <unistd.h> 
#include <string.h> 
#include <pthread.h> 
#include <errno.h> 
#include <stdio.h> 
#include <stdlib.h> 
 
void *sleeptime(void *); 
 
#define ORABM_TEST 100 
 
int main(argc, argv) 
int argc; 
char *argv[]; 
{ 
   thread_test(); 
} 
 
int thread_test() 
{ 
   int s; 
   pthread_t threads[1024]; 
   time_t now; 
   time_t start; 
   int secs; 
 
   time(&start); 
 
   secs=10; 
 
   for (s=0;s<ORABM_TEST;s++) 
   { 
      if (pthread_create(&threads[s], NULL, sleeptime, (void *)
&secs)) 
      { 
        printf("pthread_create() error=%s\n",strerror(errno)); 
      } 
      else 
      { 
        printf("pthread_create() %d\n",s); 
      } 
   } 
 
   for (s=0;s<ORABM_TEST;s++) 
   { 
      if (pthread_join(threads[s],NULL)) 
      { 
         printf("pthread_join() error=%s\n",strerror(errno)); 
      } 
      else 
      { 
        printf("pthread_join() %d\n",s); 
      } 
   } 
   time(&now); 
   printf("---start - %s",ctime(&start)); 
   printf("---end   - %s",ctime(&now)); 
} 
 
void *sleeptime(void *secs) 
{ 
   struct timespec req; 
   struct timespec rem; 
 
   req.tv_sec=*((int*)secs); 
   req.tv_nsec=0; 
   nanosleep(&req,&rem); 
   return(0); 
} 
 

Unfortunately under the RHEL Standard service level agreement we do 
not provide 
support for problems related to code development. Please see the 
following URL 
for details: 

     http://www.redhat.com/support/service/sla/rhel2_1.html

Since it appears you may have discovered a bug in RHEL AS 2.1 the 
appropriate 
place to report this issue would be: 

   http://bugzilla.redhat.com

Please let me know if you have any questions.

Regards,
Dave


Comment 2 Jakub Jelinek 2004-01-30 13:39:34 UTC
From what you wrote it is pthread_create which fails, not pthread_join.
But, I cannot reproduce this, works just fine here.
Can you perhaps strace it to see which syscall is failing and why?

Comment 3 Craig MacPherson 2004-02-06 00:15:33 UTC
Created attachment 97506 [details]
strace as requested.

Comment 4 Craig MacPherson 2004-02-06 00:19:33 UTC
Created attachment 97507 [details]
strace output as requested - first file was std io

Comment 5 Ulrich Drepper 2004-09-28 10:03:33 UTC
I cannot reproduce any problem.  Not with the current code (neither
LinuxThreads nor NPTL) and also not with an AS2.1 system.  I used:

kernel-2.4.9-e.49
glibc-2.2.4-32.17

I cannot offer any more help.  If your application depends on threads
it is in any case highly advised to use RHEL3 which features the new
thread library.  This library is much more POSIX compliant.

Comment 6 Craig MacPherson 2004-09-28 15:58:50 UTC
Thanks for the prompt attention to this matter.  Due to lack of 
support with RH Linux, we're looking at other LINUX alternatives.

Comment 7 Eric Paris 2004-10-28 21:23:09 UTC
this basically is the inability for you to create the stack for the
new pthread.  If you run

ulimit -s 1024 

in bash I was able to generate 2045 threads using your program without
running into any issues.

With the default bash stack size of 8192 I was only able to create 254
threads without a problem.

Comment 8 Eric Paris 2004-11-01 18:53:57 UTC
I also want to point out that pthread_create and pthread_join do not
set errorno and only have return calls to state they are out of
resources or they are past the max number.  See man pthread_create. 
So the "interrupted system call" is a bogus output.