Operating System - HP-UX
1832617 Members
2983 Online
110043 Solutions
New Discussion

Re: pthread_cancel not cancelling thread on HPUX 11.23 itanium server

 
SOLVED
Go to solution
Madhavi81
New Member

pthread_cancel not cancelling thread on HPUX 11.23 itanium server

I am running a multithread application on HPUX 11.23 itanium server. If i execute pthread_cancel to cancel(kill) the child thread, it doesn't work sometimes. Can comeone help me on this please?
5 REPLIES 5
Dennis Handly
Acclaimed Contributor

Re: pthread_cancel not cancelling thread on HPUX 11.23 itanium server

How do you know it isn't working?
You can only cancel a thread when it is at a cancellation point.
Madhavi81
New Member

Re: pthread_cancel not cancelling thread on HPUX 11.23 itanium server

I have set cancellation type to asynchronous(PTHREAD_CANCEL_ASYNCHRONOUS). In this case the thread should immediately get cancelled.


My application is crashing in the thread with illegal instruction error. I can see that my application has sent pthread_cancel to the child thread and started deleting the objects which it has passed as arguments to the child thread while creating it. Child thread was not killed and it crashed when trying to execute a virtual function on the deleted object.

My stack trace shows it has failed below.
#0 0x9fffffffef6b19a0 in virtual table of __cxxabiv1::__class_type_info
+0x10 ()

Dennis Handly
Acclaimed Contributor

Re: pthread_cancel not cancelling thread on HPUX 11.23 itanium server

>I have set cancellation type to asynchronous (PTHREAD_CANCEL_ASYNCHRONOUS). In this case the thread should immediately get canceled.

Do you get any errors from pthread_cancel?

pthread_cancel is not supported for aC++.
Using asynchronous is also very dangerous.

Before deleting objects, you should use pthread_kill(thread_id, 0) to see if the thread is still alive.

>My stack trace shows it has failed below.
#0 0x9fffffffef6b19a0 in virtual table of __cxxabiv1::__class_type_info +0x10

Does it have more entries?
This is a data address, not a function.
Madhavi81
New Member

Re: pthread_cancel not cancelling thread on HPUX 11.23 itanium server

No it is not throwing any error on pthread_cancel.

We use aCC compiler to compile the code. I didn't know that pthread_cancel is not supported by aCC compiler. Thanks for making me aware of this. Is there any substitute for this?

gdb shows the below.

(gdb) where
#0 0x9fffffffef6b19a0 in virtual table of __cxxabiv1::__class_type_info
+0x10 ()
warning: Attempting to unwind past bad PC 0x9fffffffef6b19a0
#1 0xc000000006278760:0 in utlCThread::ThreadStart (this=0x60000000000188a0)
at ./utl/utlThread.cpp:655
#2 0xc0000000062784f0:0 in UTL_ThreadEntryFunction (pParam=0x60000000000188a0)
at ./utl/utlThread.cpp:914
#3 0xc0000000000cd3c0:0 in __pthread_bound_body+0x190 ()
from /usr/lib/hpux64/libpthread.so.1
(gdb) info threads
* 2 system thread 7138012 0x9fffffffef6b19a0 in virtual table of __cxxabiv1::__class_type_info+0x10 ()
1 system thread 7138009 0xc000000000039890:0 in LE_is_bind_non_fatal
+0x10 () from /usr/lib/hpux64/dld.so


Line 655 in ./utl/utlThread.cpp points to a virtual function.



Dennis Handly
Acclaimed Contributor
Solution

Re: pthread_cancel not cancelling thread on HPUX 11.23 itanium server

>I didn't know that pthread_cancel is not supported by aCC compiler. Is there any substitute for this?

Not the aC++ compiler, the aC++ runtime.
You must not use the aC++ runtime. Or you must not use PTHREAD_CANCEL_ASYNCHRONOUS and then define cancellation points before you use the aC++ runtime. Or use a very limited subset of the aC++ runtime.

>Line 655 in ./utl/utlThread.cpp points to a virtual function.

I'm not sure why it points to __cxxabiv1::__class_type_info but you can't user virtual functions if the object has been destroyed.