From: Eric Dumazet <dada1@cosmosbay.com>
To: tom@kavaga.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: Possible 2.6.24-rc7 issue w/respect to pthreads
Date: Wed, 9 Jan 2008 12:07:22 +0100 [thread overview]
Message-ID: <20080109120722.262b4eff.dada1@cosmosbay.com> (raw)
In-Reply-To: <39848.76.189.45.79.1199874932.squirrel@webmail.kavaga.com>
On Wed, 9 Jan 2008 02:35:32 -0800 (PST)
tom@kavaga.com wrote:
> To Whom It May Concern,
>
> After I patched my 2.6.23 kernel to 2.6.24-rc7 this morning, I noticed
> some odd behavior with respect to POSIX threads in a test program I had
> written (originally to test epoll.)
>
> The behavior is as follows:
>
> 1. main() creates a new thread of execution with pthread_create
> 2. thread_func() immediately calls pthread_detach(), which is supposed to
> ensure that thread resources are cleaned up when the thread terminates.
> 3. The spawned thread sleeps and then prints a message "got here"
> 4. The main thread calls pthread_join(). According to the POSIX
> documentation, this should suspend execution until the spawned thread has
> terminated.
>
> What I'm seeing is that the main thread terminates immediately. If I
> comment out the call to pthread_detach(), the program runs normally. If I
> boot with my 2.6.23 kernel, the program runs normally.
>
> I'm not sure if this is some oversight on my part but similar programs
> operate correctly on my Debian etch installation with 2.6.18 as well as
> with the newer 23 kernel, but not with the patch.
>
> If you have any questions, don't hesitate to email me; my address is
> provided below.
>
> See Attached (bug.c)
>
> Tom R. Dial
> tom@kavaga.com
Hello Tom
Your program is buggy and depends on scheduling policies.
To make it fails on 2.6.23 (or say 2.6.9) too, just add a sleep(1) before pthread_join() call
Once a thread calls pthread_detach(pthread_t this_id), it's not possible anymore to
pthread_join(this_id, &ret) or effect is undefined.
(quoting POSIX : "The results of multiple simultaneous calls to pthread_join() specifying the same target thread are undefined" )
prev parent reply other threads:[~2008-01-09 11:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-09 10:35 Possible 2.6.24-rc7 issue w/respect to pthreads tom
2008-01-09 10:51 ` Marc Kleine-Budde
2008-01-09 10:53 ` Jakub Jelinek
2008-01-09 11:07 ` Eric Dumazet [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=20080109120722.262b4eff.dada1@cosmosbay.com \
--to=dada1@cosmosbay.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tom@kavaga.com \
/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