mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] pthread shouldn't ignore errors from syscall futex()
@ 2020-05-20 12:31 Konstantin Khlebnikov
  2020-05-20 16:05 ` Rich Felker
  0 siblings, 1 reply; 4+ messages in thread
From: Konstantin Khlebnikov @ 2020-05-20 12:31 UTC (permalink / raw)
  To: musl

Userspace implementations of mutexes (including glibc) in some cases
retries operation without checking error code from syscall futex.

Example which loops inside second call rather than hung (or die) peacefully:

#include <stdlib.h>
#include <pthread.h>

int main(int argc, char **argv)
{
	char buf[sizeof(pthread_mutex_t) + 1];
	pthread_mutex_t *mutex = (pthread_mutex_t *)(buf + 1);

	pthread_mutex_init(mutex, NULL);
	pthread_mutex_lock(mutex);
	pthread_mutex_lock(mutex);
}

Thread in lkml:
https://lore.kernel.org/lkml/158955700764.647498.18025770126733698386.stgit@buzz/T/

Related bug in glibc:
https://sourceware.org/bugzilla/show_bug.cgi?id=25997

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

end of thread, other threads:[~2020-05-20 17:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-20 12:31 [musl] pthread shouldn't ignore errors from syscall futex() Konstantin Khlebnikov
2020-05-20 16:05 ` Rich Felker
2020-05-20 17:38   ` Konstantin Khlebnikov
2020-05-20 17:49     ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).