Page MenuHomeFreeBSD

Several fixes for libthr, related to cancellation
Needs ReviewPublic

Authored by kib on Wed, Dec 25, 4:43 PM.
Tags
None
Referenced Files
F106185000: D48200.diff
Thu, Dec 26, 7:25 PM
F106165845: D48200.diff
Thu, Dec 26, 11:36 AM
Unknown Object (File)
Wed, Dec 25, 5:35 PM
Unknown Object (File)
Wed, Dec 25, 5:04 PM
Subscribers

Details

Reviewers
markj
Summary
thr_cancel.c: style

thr_sig.c: style


libthr: move dlerror_msg into zeroed part of struct thread

struct thread reuse might cause stalled rtld error message to propagate
to the new thread.


thr_cancel.c: use testcancel() instead of manually expanding it


pthread_setcancelstate(3): make it async-signal-safe

by setting new cancel state and reading old cancel state from the
curthread structure atomic.

Note that this does not play well with async cancellation, since if
cancellation is enabled from a signal handler and cancellation request
is pending, the thread is cancelled immediately, calling user-defined
destructors, which all must be async-signal-safe (but this is a general
requirement for async cancellation anyway).


check_cancel: when in_sigsuspend, send SIGCANCEL unconditionally

not only when check_cancel is called from the signal handler.
_thr_wake() is not enough to get the sigsuspend(2) syscall out of the
loop, since it only terminates sleep when an unblocked signal is
delivered.

PR:     283101
Tested by:      pho

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

kib requested review of this revision.Wed, Dec 25, 4:43 PM
lib/libthr/thread/thr_cancel.c
108

Don't you need to set *oldstate using the return value of atomic_swap? This code is setting *oldstate to state.

lib/libthr/thread/thr_sig.c
701
kib marked 2 inline comments as done.

More style.
Fix atomic_swap() use.