lkml.org 
[lkml]   [2002]   [Feb]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Weird bug in linux, glibc, gcc or what?

On 20020207 Felipe Contreras wrote:
>Hi,
>
>I've found a weird problem in linuxthreads. When I get out of a thread it
>happends one of three, the new thread get's defuct and the proccess never
>ends, it segfaults, or it works.
>
>The most weird is that it depends on the kernel, and also when I run the
>test trought gdb there is no problem.
>
>Here is the test:
>
>#include <pthread.h>
>
>void *test(void *arg) {
> puts("Thread2");
> return 0;
>}
>
>int main() {
> pthread_t tt;
> puts("Before Thread2");
> pthread_create(&tt,NULL,test,NULL);
> puts("After Thread2");
> return 0;
>}
>

Buggy program that could give unspecified behaviour, unless pthread
standard talks about orphaned threads...

Your main program can die (exit) before child thread ends, so it has
nobody to notify its dying or return to.

Try with a sleep(1) before main return, or better, do a
pthread_join().

--
J.A. Magallon # Let the source be with you...
mailto:jamagallon@able.es
Mandrake Linux release 8.2 (Cooker) for i586
Linux werewolf 2.4.18-pre9-slb #3 SMP Fri Feb 8 01:33:12 CET 2002 i686
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:24    [W:0.030 / U:34.060 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site