This is the mail archive of the libc-alpha@sourceware.cygnus.com 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]

["E. Jay Berkenbilt" <ejb@ql.org>] libc/1223: exec does not cause multiple threads to exit



Is this a known limitation of linuxthreads?  Any chance to get this
fixed?

Andreas



Topics:
   libc/1223: exec does not cause multiple threads to exit


----------------------------------------------------------------------

Date: Mon, 26 Jul 1999 20:06:55 -0400
From: "E. Jay Berkenbilt" <ejb@ql.org>
To: bugs@gnu.org
Cc: ejb@ql.org
Subject: libc/1223: exec does not cause multiple threads to exit
Message-Id: <199907270006.UAA01970@soup.ql.org>


>Number:         1223
>Category:       libc
>Synopsis:       exec in multithreaded program does not cause threads to exit
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    libc-gnats
>State:          open
>Class:          sw-bug
>Submitter-Id:   unknown
>Arrival-Date:   Mon Jul 26 20:10:01 EDT 1999
>Last-Modified:
>Originator:     E. Jay Berkenbilt
>Organization:
 
>Release:        libc-2.1.1
>Environment:
	
Host type: i386-redhat-linux-gnu
System: Linux soup.ql.org 2.2.5-15 #1 Mon Apr 19 23:00:46 EDT 1999 i686 unknown
Architecture: i686

Addons: crypt glibc-compat linuxthreads
Build CFLAGS: -g -O3
Build CC: egcs
Compiler version: egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
Kernel headers: 2.2.5-15
Symbol versioning: yes
Build static: yes
Build shared: yes
Build pic-default: no
Build profile: yes
Build omitfp: no
Build bounded: no
Build static-nss: no
Stdio: libio

>Description:
	The POSIX Threads standard states that calling exec from any
	thread in a multithreaded program causes all threads to exit.
	The pthreads implementation in Linux 2.2.x with glibc 2.1.1
	does not conform to this.
>How-To-Repeat:

The following program (includes in double quotes instead of angle
brackets because I'm afraid glibcbug will strip them and haven't
bothered to find out...) illustrates the bug.  The two child threads
should both exit at the time of the call to exec.  However, they don't
exit until the process run by exec exits.

#include "stdlib.h"
#include "pthread.h"

void* fn(void* arg)
{
    int pid = getpid();
    int tid = pthread_self();
    while (1)
    {
	printf("%d %d\n", pid, tid);
	sleep(1);
    }
    return 0;
}

int main(int argc, char* argv[])
{
    pthread_t th1;
    pthread_t th2;
    pthread_create(&th1, 0, fn, 0);
    pthread_create(&th2, 0, fn, 0);
    sleep(3);
    printf("calling exec\n");
    execl("/bin/sleep", "sleep", "5", 0);
    abort();
    return 0;
}

>Fix:
	I don't know the fix.  There's no reason that threads created
	with the Linux-specific clone() call need to exit when the
	creating process exits.  I don't know how execve would be able
	to tell the difference between a thread created with
	pthread_create() and one created with clone() when it came
	time to decide what threads to eliminate after a fork.  I
	don't know whether this is a kernel issue or a library issue.
>Audit-Trail:
>Unformatted:


------------------------------

End of forwardlnBAxC Digest
***************************



-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@aixd1.rhrk.uni-kl.de

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