pthread_join hang on glibc2.5


 
Thread Tools Search this Thread
Operating Systems Linux pthread_join hang on glibc2.5
# 1  
Old 11-04-2008
pthread_join hang on glibc2.5

Hello All,
The problem i'm experiencing is with the following code:

#include <pthread.h>
#include <stdio.h>

int main(void)
{
(void) pthread_join(155555, NULL);
printf("done");
return 0;
}

I'm getting on terminal segmentation fault .
System used: CentOS release 5 (Final)
Kernel: 2.6.18-53.1.4.el5
GCC : gcc (GCC) 4.1.1 20070105 (Red Hat 4.1.1-52)
GLIBC:GNU C Library stable release version 2.5, by Roland McGrath et al.
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.1.1 20061011 (Red Hat 4.1.1-30).
Compiled on a Linux 2.6.9 system on 2007-03-14.

pthread_join according to the man should return ERROR in case the thread doesn't exist.

I checked the same code on Red Hat 9 ,2.4.20-31.9, gcc 3.4.3 and GLIBC 2.3.2 and the code returns Error code as expected.

This looks to me as very common use of pthread_join and yet i can't find reference on the web about this error, nor bug listed.

Can someone help ?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

ALOM hang

Hi guys, I'm new with solaris. I just received sunfire T2000 server. Problem: ALOM keep hang/stuck/jammed. Steps do before it hang : 1. Connect to T2000 (using RJ45 - DB9 cable) 2. Open putty, connect via serial. 3. Power on the server. 4. Its loading. 5. then, hang. ... (1 Reply)
Discussion started by: rajasraf
1 Replies

2. IP Networking

netstat -a hang

Hi, on our Solaris 10 servers, one day 'netstat -a' command return very slow after TCP output, wait 5 minute on this line - SCTP: Local Address Remote Address Swind Send-Q Rwind Recv-Q StrsI/O State ------------------------------- ------------------------------- ------ ------ ------ ------... (6 Replies)
Discussion started by: ora_dba
6 Replies

3. Programming

pthread_exit and pthread_join usage

Hi... this simple code has warning messages but it work.. void *th(void *g){ int y = 10; pthread_exit((void*)y); } int main(int argn, char ** argp){ void * ret; pthread_t thread; pthread_create(&thread, NULL, th, NULL); pthread_join(thread,... (10 Replies)
Discussion started by: prompt
10 Replies

4. Programming

Doubt on pthread_exit and pthread_join

Main function creates Thread0 and Thread1 by using pthread_create systemcall. In Thread0() { we are calling pthread_exit(0) ; } and in Thread1() { status= pthread_join(tid,NULL); sprintf(ebuf,"timer6: can't join with thread0, status: %d",status); Assert(status==0,ebuf); } ... (4 Replies)
Discussion started by: mansa
4 Replies

5. UNIX for Advanced & Expert Users

pthread_join function

Hi, I would like to know if the call of pthread_join( thread,&status) for a thread already created in main function will free the memory allocated to thread after the pthread_join retruns or should I wait the termination of main function? Is there any need to cancel or exit the thread if I... (0 Replies)
Discussion started by: Behnaz
0 Replies

6. AIX

Boot from CD hang

Why is one of my blade hanging and does nothing after trying to boot from CD??? ================== I tried to press 1....JS20 does not support SMS menu Here's what I see after 30 minutes... ------------------------------------------------------------------------------- ... (0 Replies)
Discussion started by: mifch
0 Replies

7. Shell Programming and Scripting

Ftp hang

Im making a script that goes out to about 200 servers and grabs log files daily and need to make sure the script gets all the servers it can even if one is out. I am ftp'ing the files over but if i cant connect to the server the process looks like it dies and the script is finished. (4 Replies)
Discussion started by: rcunn87
4 Replies

8. Red Hat

system hang

Hello, I am having a HP proliant 350 G3 sever installed wih RedHat linux 9.0 when I enterd using any user(Except root) the server hanged after few seconds, also the folder icons are blacked out and the names of the folder icons are disapper. can any body help me. Ajay (1 Reply)
Discussion started by: ajay234
1 Replies

9. UNIX for Dummies Questions & Answers

How to write my own version of pthread_join()

I would like to write my own version of pthread_join and some of the other pthread function. Does some know any pages that have som examples of doing this?? (1 Reply)
Discussion started by: bigblop
1 Replies

10. Linux

Help for Linux hang up

Hi everybody, i need help regarding my Linux start up.I was trying to configure internet connection with my Red Hat in order to use for Internet,but of no avail and I think I have changed one parameter to activate device during computer start up. Now the problem is during start up and... (1 Reply)
Discussion started by: andysastre
1 Replies
Login or Register to Ask a Question
PTHREAD_JOIN(3)                                              Linux Programmer's Manual                                             PTHREAD_JOIN(3)

NAME
pthread_join - join with a terminated thread SYNOPSIS
#include <pthread.h> int pthread_join(pthread_t thread, void **retval); Compile and link with -pthread. DESCRIPTION
The pthread_join() function waits for the thread specified by thread to terminate. If that thread has already terminated, then pthread_join() returns immediately. The thread specified by thread must be joinable. If retval is not NULL, then pthread_join() copies the exit status of the target thread (i.e., the value that the target thread supplied to pthread_exit(3)) into the location pointed to by retval. If the target thread was canceled, then PTHREAD_CANCELED is placed in the loca- tion pointed to by retval. If multiple threads simultaneously try to join with the same thread, the results are undefined. If the thread calling pthread_join() is canceled, then the target thread will remain joinable (i.e., it will not be detached). RETURN VALUE
On success, pthread_join() returns 0; on error, it returns an error number. ERRORS
EDEADLK A deadlock was detected (e.g., two threads tried to join with each other); or thread specifies the calling thread. EINVAL thread is not a joinable thread. EINVAL Another thread is already waiting to join with this thread. ESRCH No thread with the ID thread could be found. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +---------------+---------------+---------+ |Interface | Attribute | Value | +---------------+---------------+---------+ |pthread_join() | Thread safety | MT-Safe | +---------------+---------------+---------+ CONFORMING TO
POSIX.1-2001, POSIX.1-2008. NOTES
After a successful call to pthread_join(), the caller is guaranteed that the target thread has terminated. The caller may then choose to do any clean-up that is required after termination of the thread (e.g., freeing memory or other resources that were allocated to the target thread). Joining with a thread that has previously been joined results in undefined behavior. Failure to join with a thread that is joinable (i.e., one that is not detached), produces a "zombie thread". Avoid doing this, since each zombie thread consumes some system resources, and when enough zombie threads have accumulated, it will no longer be possible to create new threads (or processes). There is no pthreads analog of waitpid(-1, &status, 0), that is, "join with any terminated thread". If you believe you need this function- ality, you probably need to rethink your application design. All of the threads in a process are peers: any thread can join with any other thread in the process. EXAMPLE
See pthread_create(3). SEE ALSO
pthread_cancel(3), pthread_create(3), pthread_detach(3), pthread_exit(3), pthread_tryjoin_np(3), pthreads(7) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2017-09-15 PTHREAD_JOIN(3)