- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- pthread_cond_wait crashes on HPUX10.20
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2003 02:26 AM
06-27-2003 02:26 AM
pthread_cond_wait crashes on HPUX10.20
I use gcc 3.2.2 on HPUX10.20 and DCE thread library (libcma is used). It was configured with the following switches:
Reading specs from /usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/3.2.2/specs
Configured with: ../gcc-3.2.2/configure --enable-shared --disable-threads --enable-languages=c,c++,f77
Thread model: single
gcc version 3.2.2
The following piece of code crashes:
=============================================
#include
#include
int main(int argc, char* argv[])
{
pthread_mutex_t * hMutex = new pthread_mutex_t;
pthread_cond_t * hEvent = new pthread_cond_t;
// Mutex Initialization
pthread_mutexattr_t attr;
int ret1, ret2, ret3;
if( (ret1=::pthread_mutexattr_create(&attr)) != 0 || (ret2=::pthread_mutexattr_setkind_np(&attr, MUTEX_RECURSIVE_NP)) != 0 ||
(ret3 = ::pthread_mutex_init(hMutex, attr)) != 0 )
{
printf( "Ret1 = %d, ret2 = %d, ret3 = %d\n", ret1, ret2, ret3);
exit(0);
}
::pthread_mutexattr_delete(&attr);
// Event Initialization
pthread_condattr_t condattr;
::pthread_condattr_create(&condattr);
if( ::pthread_cond_init(hEvent, condattr) != 0 )
printf ("Event Initialization failed\n");
::pthread_condattr_delete(&condattr);
pthread_mutex_lock(hMutex);
// inifinte
printf ("Wait infinitely ...\n");
pthread_cond_wait(hEvent, hMutex);
return 0;
}
==============================================
The program output is:
Wait infinitely ...
Segmentation fault (core dumped)
Notes:
1)When compiling the program with aCC, the same code produces:
Wait infinitely ..
Bus error (core dumped)
2) Using pthread_cond_timedwait instead of pthread_cond_wait does not
crash, it returns -1 and sets errno to EAGAIN, indicating that the wait time has elapsed
3) The same piece of code works fine on LINUX
(of course, some pthread function names were modified correspondingly for LINUX)
Question: Any ideas what could cause a crash of
pthread_cond_wait?
Thank you in advance,
Arthur Prosso
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2003 05:25 AM
06-27-2003 05:25 AM
Re: pthread_cond_wait crashes on HPUX10.20
I dont see any problem in the code. Did you a get a backtrace on the core. Post the backtrace.
I always linked libdce.a instead of libcma.a. Can you try linking with libdce.a and get back with the results.
HTH,
Umapathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2003 05:57 AM
06-27-2003 05:57 AM
Re: pthread_cond_wait crashes on HPUX10.20
Thank you for reply.
The core examination adds too few info:
Core was generated by `test'.
Program terminated with signal 11, Segmentation fault.
#0 0xc1bef274 in ??
> backtrace
#0 0xc1bef274 in ?? ()
Cannot access memory at address 0xc1bef118
I tried to link with libdce.a - with the same result, but!!!
I tried to run pthread_cond_wait in a separate thread and it worked. Very strange. I don't see any reason why pthread_cond_wait shoud not work in a single threaded app.
Maybe now you will have any more ideas?
Thank you,
Arthur
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2003 06:53 AM
06-27-2003 06:53 AM
Re: pthread_cond_wait crashes on HPUX10.20
Man page of pthread_mutexattr_setkind_np says like this.
Never use a recursive mutex with condition variables because the
implicit unlock performed for a pthread_cond_wait() or
pthread_cond_timedwait() might not actually release the mutex. In that
case, no other thread can satisfy the condition of the predicate.
This routine is a new primitive.
So, the thread is actually timing out and dumps with a SIGBUS for data corruption. I changed the program to C, compiled and ran. It dumped core. I tried to view the core and gdb itself dumped. I dont know the reason.
HTH,
Umapathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-30-2003 08:03 AM
06-30-2003 08:03 AM
Re: pthread_cond_wait crashes on HPUX10.20
I have it nailed out for you.
It appeares the problem is that some initialisation of cma internal structuresess that authors decided that there is no point to use synchronisation, while you have only one thread.
Try to start a new thread before calling pthread_mutex_lock().
Just in case - I did it for you and it worked.
However I can also say that according to man pages using recursive mutexes with conditional variables is not the good idea.
Also - if you live C++ way move the initialisation part to the constructors, and deallocation in destructors - this is the meaning of their existance. Frankly - that's what I really did in my code. And of course you don't have to allocate mutex and conditional_variable dynamicaly - you can use automatic variables, just like you did with attributes. But thats not the point.
Good luck
Adam