- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Pthread mutex crash before main
Operating System - HP-UX
1821641
Members
3281
Online
109633
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО01-31-2002 05:51 PM
тАО01-31-2002 05:51 PM
Pthread mutex crash before main
Hi,
I have been experiencing a weird problem with one of my threaded applications, I have managed to reproduce in a small example where i have a stl::string and i link in pthreads. If i dont link pthread OR remove the stl::string then it works.
The following is the test code:
#include
#include
#include
using namespace std;
int main(int argc, char *argv[])
{
string hw("hello world");
printf( "%s\n", hw.c_str() );
return 0;
}
using compile line:
aCC -AA +DA2.0W -o pthreadTest pthreatest.cpp -lpthread
aCC --version :
aCC: HP ANSI C++ B3910B A.03.30
uname -a :
HP-UX borneo B.11.00 U 9000/785 2013089457 unlimited-user license
also whats weird when i do a ldd on the exe i get the following:
ldd pthreadTest
libpthread.1 => /usr/lib/pa20_64/libpthread.1
libstd_v2.2 => /usr/lib/pa20_64/libstd_v2.2
libCsup_v2.2 => /usr/lib/pa20_64/libCsup_v2.2
libm.2 => /usr/lib/pa20_64/libm.2
libcl.2 => /usr/lib/pa20_64/libcl.2
libc.2 => /usr/lib/pa20_64/libc.2
libdl.1 => /usr/lib/pa20_64/libdl.1
libdl.1 => /usr/lib/pa20_64/libdl.1
libdl.1 => /usr/lib/pa20_64/libdl.1
/opt/graphics/OpenGL/lib/pa20_64/libogltls.sl => /opt/graphics/OpenGL/lib/pa20_64/libogltls.sl
Why am i linking to openGL?
someone please help! :)
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-11-2002 09:30 AM
тАО09-11-2002 09:30 AM
Re: Pthread mutex crash before main
I am running into the same issue. Did you find the fix?
Neeraj
Neeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-11-2002 09:58 AM
тАО09-11-2002 09:58 AM
Re: Pthread mutex crash before main
I managed to get around this problem by using the following compile line:
aCC -AA +DA2.0W -o pthreadTest pthreatest.cpp -mt
basically i replaced -lpthreas with -mt.
I hope this helps someone.
aCC -AA +DA2.0W -o pthreadTest pthreatest.cpp -mt
basically i replaced -lpthreas with -mt.
I hope this helps someone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2002 02:29 AM
тАО10-23-2002 02:29 AM
Re: Pthread mutex crash before main
Hi
I think that the problem lies in the string implementation. It was made in the way that several identical strings share the same buffer instead of copying it exclusivelly for themseves. This leads to the concept of reference counters that are attached to every string buffer.
Unluckilly, because strings can be used from several threads, access to this reference counter has to be synchronized to avoid modifications from several threads at the same time. So together with this buffer we have also mutex.
But there is a lot of programs that are not multithread, so why to use mutex and multithread library always? Thats why it was decided that adding mutex to the string buffer will be dane only if it will be discovered that the program is compiled for multithread.
And comes your problem, I suppose. Some of the used code (libraries, objects) are compiled for not multithread and construct strings that use buffers without mutex attached. When it comes to the code that tries to work with mutex that is not allocated then you have a crash.
I've been using strings with pthread whith a success. I use -D__REENTRANT to enforce multithread strings everywhere. But if you use library that uses strings without mutexes it will be more difficult.
Good luck
Adam
I think that the problem lies in the string implementation. It was made in the way that several identical strings share the same buffer instead of copying it exclusivelly for themseves. This leads to the concept of reference counters that are attached to every string buffer.
Unluckilly, because strings can be used from several threads, access to this reference counter has to be synchronized to avoid modifications from several threads at the same time. So together with this buffer we have also mutex.
But there is a lot of programs that are not multithread, so why to use mutex and multithread library always? Thats why it was decided that adding mutex to the string buffer will be dane only if it will be discovered that the program is compiled for multithread.
And comes your problem, I suppose. Some of the used code (libraries, objects) are compiled for not multithread and construct strings that use buffers without mutex attached. When it comes to the code that tries to work with mutex that is not allocated then you have a crash.
I've been using strings with pthread whith a success. I use -D__REENTRANT to enforce multithread strings everywhere. But if you use library that uses strings without mutexes it will be more difficult.
Good luck
Adam
I do everything perfectly, except from my mistakes
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP