public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "J.A. Magallon" <jamagallon@able.es>
To: Felipe Contreras <al593181@mail.mty.itesm.mx>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: Weird bug in linux, glibc, gcc or what?
Date: Fri, 8 Feb 2002 15:43:32 +0100	[thread overview]
Message-ID: <20020208154332.A3336@werewolf.able.es> (raw)
In-Reply-To: <20020207135749.GA4545@sion.mty.itesm.mx>
In-Reply-To: <20020207135749.GA4545@sion.mty.itesm.mx>; from al593181@mail.mty.itesm.mx on jue, feb 07, 2002 at 14:57:49 +0100


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

      parent reply	other threads:[~2002-02-08 14:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-07 13:57 Weird bug in linux, glibc, gcc or what? Felipe Contreras
2002-02-08  9:48 ` Catalin Marinas
2002-02-08 14:43 ` J.A. Magallon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020208154332.A3336@werewolf.able.es \
    --to=jamagallon@able.es \
    --cc=al593181@mail.mty.itesm.mx \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox