mailing list of musl libc
 help / color / Atom feed
* [musl] pthread_getspecific(3) with negative key
@ 2020-07-08  8:59 Alexander Scherbatiy
  2020-07-08 10:40 ` Florian Weimer
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Scherbatiy @ 2020-07-08  8:59 UTC (permalink / raw)
  To: musl

Hello,

The pthread_getspecific(3) specification describes:
   "The pthread_getspecific() function shall return the thread-specific 
data value associated with the given key. If no thread-specific data 
value is associated with key, then the value NULL shall be returned. "

The glibc version pthread_getspecific(3) returns NULL for the negative 
key value.
The musl version does not check key bounds [1].
Is it intentional behavior?

[1] 
https://git.musl-libc.org/cgit/musl/tree/src/thread/pthread_getspecific.c#n7

Thanks,
Alexander.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [musl] pthread_getspecific(3) with negative key
  2020-07-08  8:59 [musl] pthread_getspecific(3) with negative key Alexander Scherbatiy
@ 2020-07-08 10:40 ` Florian Weimer
  0 siblings, 0 replies; 2+ messages in thread
From: Florian Weimer @ 2020-07-08 10:40 UTC (permalink / raw)
  To: Alexander Scherbatiy; +Cc: musl

* Alexander Scherbatiy:

> The pthread_getspecific(3) specification describes:
>   "The pthread_getspecific() function shall return the thread-specific
> data value associated with the given key. If no thread-specific data
> value is associated with key, then the value NULL shall be returned. "

POSIX says this:

| The effect of calling pthread_getspecific() or pthread_setspecific()
| with a key value not obtained from pthread_key_create() or after key
| has been deleted with pthread_key_delete() is undefined.

So no check for a valid key is required.

Thanks,
Florian


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-08  8:59 [musl] pthread_getspecific(3) with negative key Alexander Scherbatiy
2020-07-08 10:40 ` Florian Weimer

mailing list of musl libc

Archives are clonable: git clone --mirror http://inbox.vuxu.org/musl

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.musl


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git