Complete fix to cancellation/stack unwinding problem of deferred Posix threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Complete fix to cancellation/stack unwinding problem of deferred Posix threads



Before going into specifics I post the question:
Are there plans to fix terminal bugs with cancellation/stack unwinding
of deferred Posix threads?

My test program attempted to cancel deferred thread whose cancellation
state is enabled before call to pthread_canceltest and is disabled
immediately afterwards.

When such thread is being cancelled on 2.4 kernel with gcc 3.2.3 the
test program crashes with 'FATAL: exception not rethrown'. Rethrowing
system (catch ...) exception made no difference.

Same test program does not crash when build and run on 2.6 kernel with
gcc 3.3.3 but instead it deadlocks with corrupted stack soon (~2 sec)
after call to pthread_cancel:
	(gdb) where
	#0  0xffffe415 in ?? ()
	#1  0xbfffdf2c in ?? ()
	#2  0x00000002 in ?? ()
	#3  0x00000000 in ?? ()
	#4  0x4035ebfe in __lll_mutex_lock_wait () from
/lib/tls/libpthread.so.0
	#5  0x4035bc00 in _L_mutex_lock_33 () from
/lib/tls/libpthread.so.0
	#6  0x00001000 in ?? ()
	#7  0x40349bd0 in
__elf_set___libc_thread_subfreeres_element___rpc_thread_destroy__ ()
	   from /lib/tls/libc.so.6
	#8  0x40c62360 in ?? ()
	#9  0xbfffe454 in ?? ()
	#10 0xbfffdfa4 in ?? ()
	#11 0x40c669f9 in _nss_files_gethostbyname_r () from
/lib/libnss_files.so.2
	Previous frame identical to this frame (corrupt stack?)
I see two problems:
1) pthread_cancel() cancels thread before reaching cancellation point in
pthread_testcancel()
2) stack gets corrupted during unwind.

Since the behavior changed, - from crash to deadlock (an improvement in
a way :), - I want to ask what thread cancellation bugs were fixed on
2.6 kernel + gcc 3.3.3, and, more importantly, when the patch with
complete fix (no stack corruption, no crash) will become available.

I realize that the above details should be posted on bugzilla but wanted
to asked my question here. I was referred to this list by an owner of
bug 111548 who indicated that the decision of when and if the fix will
be made rests with some members of C++-pthreads:
http://bugzilla.redhat.com/bugzilla/long_list.cgi?buglist=111548

It is pity that so complete pthreads implementation is not fully usable
in spite the fact that thread cancellation/stack unwinding problems are
known for some time (I've read relevant discussion threads of this
group).

    George