cosmopolitan/libc/intrin/stack.h
Justine Tunney e939659b70
Fix ordering of pthread_create(pthread_t *thread)
This change fixes a bug where signal_latency_async_test would flake less
than 1/1000 of the time. What was happening was pthread_kill(sender_thr)
would return EFAULT. This was because pthread_create() was not returning
the thread object pointer until after clone() had been called. So it was
actually possible for the main thread to stall after calling clone() and
during that time the receiver would launch and receive a signal from the
sender thread, and then fail when it tried to send a pong. I thought I'd
use a barrier at first, in the test, to synchronize thread creation, but
I firmly believe that pthread_create() was to blame and now that's fixed
2025-01-03 17:34:29 -08:00

14 lines
377 B
C

#ifndef COSMOPOLITAN_LIBC_STACK_H_
#define COSMOPOLITAN_LIBC_STACK_H_
#include "libc/thread/thread.h"
COSMOPOLITAN_C_START_
void cosmo_stack_lock(void);
void cosmo_stack_unlock(void);
void cosmo_stack_wipe(void);
bool TellOpenbsdThisIsStackMemory(void *, size_t);
bool FixupCustomStackOnOpenbsd(pthread_attr_t *);
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_STACK_H_ */