Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 10 Feb 2020 14:34:27 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: No such process return value in pthread_getcpuclockid

On Mon, Feb 10, 2020 at 10:29:02PM +0300, Alexander Scherbatiy wrote:
> Hello,
> 
> It seems that pthread_getcpuclockid does not properly handle non
> valid thread id argument.
> 
> Below is a sample which calls pthread_getcpuclockid with NULL thread
> id. The expected result is ESRCH (No thread with the ID thread could
> be found). It crashes in my docker with Alpine Linux 3.11.3 (musl
> libc x86_64 1.1.24). It returns ESRCH on my Ubuntu system.

There's no such thing as a "null thread id". A pthread_t value is
either the id of a thread which is still valid (still running or
joinable and not yet joined), or *any* use of it produces undefined
behavior. There is no value reserved for a sentinel. If you need an
optional thread id variable/field, you need a separate validity flag
alongside it.

None of this is unique to musl; it's the way the POSIX threads
interfaces are designed.

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.