public inbox for
 help / color / mirror / Atom feed
From: Ross Johnson <>
To: pthreads-win32 <>
Subject: Re: snap-2004-11-03 breakage
Date: Wed, 03 Nov 2004 16:19:00 -0000	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

Alexander Terekhov wrote:

>>Code like (from Ettercap)
>>  pthread_t pid = ec_thread_getpid("golem");
>>  if (pid != 0)
>>    ec_thread_destroy(pid);
>Code it like
>  pthread_t tid;
>  if (ec_thread_getpid("golem",&tid)
>    ec_thread_destroy(tid);
But how does ec_thread_getpid() portably determine if the thread
exists or not?

>Don't rely on idiotic pthread_kill() "testing". The standard 
>doesn't preclude the use of pointers for thread IDs (e.g. 
>inside pthread_t structure).
Oops. I should have recognised that because ...

>Pointers become indeterminate and
>trigger undefined behavior for any nonassignment access once 
>the reference storage gets freed. Conforming implementations 
>are allowed to reclaim/free that referenced storage when 
>detached thread is terminated or joinable thread is terminated 
>and joined. Use of "retired" pthread_t values (e.g. as 
>pthread_kill() argument) after that moment will trigger 
>undefined behavior. 
... that's exactly why pthread_t was changed in pthreads-win32.

Every function that takes a thread ID argument has the same problem
as pthread_kill() if pointers are used.



  reply	other threads:[~2004-11-03 16:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-03 13:18 Gisle Vanem
2004-11-03 14:28 ` Robert Kindred
2004-11-03 16:18   ` Ross Johnson
2004-11-03 16:30     ` Peter Slacik
2004-11-04 18:06     ` Robert Kindred
2004-11-03 14:33 ` Ross Johnson
     [not found] ` <>
2004-11-03 15:02   ` Gisle Vanem
2004-11-03 15:38     ` Ross Johnson
2004-11-03 15:32 ` Alexander Terekhov
2004-11-03 16:19   ` Ross Johnson [this message]
2004-11-03 16:32     ` Alexander Terekhov
2004-11-03 16:15 Bossom, John

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:

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

  git send-email \ \ \ \

* 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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).