aboutsummaryrefslogtreecommitdiff
path: root/sysdeps/unix
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2021-03-04 15:15:33 +0100
committerJakub Jelinek <jakub@redhat.com>2021-03-04 15:15:33 +0100
commitf0419e6a10740a672b28e112c409ae24f5e890ab (patch)
tree48034df63bcf917ba4a4b59c6c9238798e67e233 /sysdeps/unix
parent82215c1e251cf9a4668608974784c412d09c7ccd (diff)
downloadglibc-f0419e6a10740a672b28e112c409ae24f5e890ab.tar
glibc-f0419e6a10740a672b28e112c409ae24f5e890ab.tar.gz
glibc-f0419e6a10740a672b28e112c409ae24f5e890ab.tar.bz2
glibc-f0419e6a10740a672b28e112c409ae24f5e890ab.zip
[PATCH] pthread_once hangs when init routine throws an exception [BZ #18435]
This is another attempt at making pthread_once handle throwing exceptions from the init routine callback. As the new testcases show, just switching to the cleanup attribute based cleanup does fix the tst-once5 test, but breaks the new tst-oncey3 test. That is because when throwing exceptions, only the unwind info registered cleanups (i.e. C++ destructors or cleanup attribute), when cancelling threads and there has been unwind info from the cancellation point up to whatever needs cleanup both unwind info registered cleanups and THREAD_SETMEM (self, cleanup, ...) registered cleanups are invoked, but once we hit some frame with no unwind info, only the THREAD_SETMEM (self, cleanup, ...) registered cleanups are invoked. So, to stay fully backwards compatible (allow init routines without unwind info which encounter cancellation points) and handle exception throwing we actually need to register the pthread_once cleanups in both unwind info and in the THREAD_SETMEM (self, cleanup, ...) way. If an exception is thrown, only the former will happen and we in that case need to also unregister the THREAD_SETMEM (self, cleanup, ...) registered handler, because otherwise after catching the exception the user code could call deeper into the stack some cancellation point, get cancelled and then a stale cleanup handler would clobber stack and probably crash. If a thread calling init routine is cancelled and unwind info ends before the pthread_once frame, it will be cleaned up through self->cleanup as before. And if unwind info is present, unwind_stop first calls the self->cleanup registered handler for the frame, then it will call the unwind info registered handler but that will already see __do_it == 0 and do nothing.
Diffstat (limited to 'sysdeps/unix')
0 files changed, 0 insertions, 0 deletions