Opened 7 years ago

Last modified 3 years ago

#9771 assigned bug

_single_threaded not updated in case of SIGEV_THREAD

Reported by: bonefish Owned by: nobody
Priority: normal Milestone: R1
Component: System/libroot.so Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

libroot's _single_threaded global variable (<stdio_post.h>) is only updated in spawn_thread(). A SIGEV_THREAD signal handler will also create a thread, but the variable won't be set in that case, since it is only done in spawn_thread(). By the time the thread has been created, it may be too late to set the flag, since the main thread may already be in the middle of a libroot function that requires locking in a multi-threaded program, so it is probably best to set the variable already when the signal handler is set.

A similar problem (without solution) exists when a thread is created in a signal handler function.

It should also be considered to alias {getc,putc}_unlocked() with the locking version and omit the variable (save for keeping the storage for binary compatibility).

Change History (2)

comment:1 by axeld, 7 years ago

Since the performance impact will probably be acceptable anyway, I wouldn't mind keeping it always off. If that is not an option (do we have some benchmarks for this?), we could also just document the spawn thread in exception handler problem, or make it always off as soon as any signal handler is set.

At least it does not sound likely to me that a single threaded application will use an additional thread in an exception handler.

comment:2 by axeld, 3 years ago

Owner: changed from axeld to nobody
Status: newassigned
Note: See TracTickets for help on using tickets.