Operating System - HP-UX
1827473 Members
2489 Online
109965 Solutions
New Discussion

Core Dumped while linking with -lpthread & works if -lpthread is removed

 
hcl-chennai
Occasional Contributor

Core Dumped while linking with -lpthread & works if -lpthread is removed

The application dumped core when it has been linked with -lpthread option.
At the same time it is working fine without linking with -lpthread option.

*******************************************
///sample program test.cpp
#include
#include
#include
using namespace std;
long givelong();

int main()
{
long n=98l;
string testrw("MyFile");
ofstream fp_;
fp_.open(testrw.data());
const string s="TEST1";
fp_ << s <<" ---" < fp_ << testrw.data() << n << endl;
fp_ << testrw.data() << n << "Hello" << endl;
return 0;
}
long givelong(){
long ln=901l;
return ln;
}

==============================================
compilation option:
------------------
/opt/aCC/bin/aCC -c -DHPUX +W392,431,655,684,818,823 -w -Wl,+s +DAportable +ESnolit -g -I./ -AA -D_REENTRANT -g test.cpp

-o testRW.o
/opt/aCC/bin/aCC -DHPUX +W392,431,655,684,818,823 -w -Wl,+s +DAportable +ESnolit -g -I./ -AA -D_REENTRANT -o testRW.out

testRW.o -lpthread
==============================================
Core Dumped :
-----------
#0 0xc020c4b0 in kill+0x10 () from /usr/lib/libc.2
#1 0xc01a6c74 in raise+0x24 () from /usr/lib/libc.2
#2 0xc01e70e0 in abort_C+0x160 () from /usr/lib/libc.2
#3 0xc01e713c in abort+0x1c () from /usr/lib/libc.2
#4 0xc28c34f0 in std::terminate+0x38 () from /usr/lib/libCsup_v2.2
#5 0xc28c39b8 in ThrowException+0x74 () from /usr/lib/libCsup_v2.2
#6 0xc28c3f18 in __throw__FPvT1+0x14c () from /usr/lib/libCsup_v2.2
#7 0xc4e00674 in std::ios_base::setf+0x7c () from /usr/lib/libstd_v2.2
#8 0xc4e00118 in std::ios_base::Init::Init+0x1e40 () from /usr/lib/libstd_v2.2
#9 0x225f4 in std::__sinit_test_cpp+0x28 ()
from /u01/kla-tencor/klarity/test/./testRW.out
#10 0xc28c7200 in __mainHelper+0x40 () from /usr/lib/libCsup_v2.2
#11 0xc28c7534 in _main+0xec () from /usr/lib/libCsup_v2.2
**********************************************
4 REPLIES 4
Muthukumar_5
Honored Contributor

Re: Core Dumped while linking with -lpthread & works if -lpthread is removed

Which platform did you try -lpthread for compilation.?

Your sample program is not using any thread related functions?

There is a problem when you -lpthread on 11.23 with memory leak issues. Search in forums with 11.23 -lpthread keyword.
Easy to suggest when don't know about the problem!
hcl-chennai
Occasional Contributor

Re: Core Dumped while linking with -lpthread & works if -lpthread is removed

Hi,

We compile & run the above program in HP-UX 11i. Compiler Used: aCC A.03.45

Basically we're moving from aCC A.03.27 to A.03.45. We compiled our existing source code with A.03.45 and noticed that the ofstream object is not working. i.e all strings are written to the output file, but the long datavalues are not written to the output file.

So we tried the above test program. If we don't link the above program with pthread library, its working fine.

Since our original program which is a Pro*C++ application, which uses pthread, we tried the sample program also to link with pthread just to narrow down the problem.

Even though we don't use any of the pthread related items, why does the code dump core?
Christian Deutsch_1
Esteemed Contributor

Re: Core Dumped while linking with -lpthread & works if -lpthread is removed

Dear Chennai,

Did you contact HP support about this?

Kind regards, Christian
Yeshua loves you!
Laurent Laperrousaz
Regular Advisor

Re: Core Dumped while linking with -lpthread & works if -lpthread is removed

you should submit your problem to :
cxx-dev@cxx.cup.hp.com
they surely have a solution to your problem

regards

Laurent