CC 5.5 ostream issue: Program receving signal SEGV in multi thread env

Hi Friends,

We are using Solaris 5.9, in a V880 machine and Sun CC 5.5 compiler.

We have a multi-threaded application, and we are using -lpthread.

We use "cout" option for our console logging. The logging mechanism works fine initially, but as soon as we create a new thread, from the new thread "cout" receive SEGV signal. We got the following dbx trace.

=================================

l@6) signal SEGV (no mapping at the fault addr

ess) in std::basic_filebuf<char,std::char_traits><char> >::xsputn at 0xfeab5718

0xfeab5718: xsputn+0x0124:stb%l2, [%l3]

Current function is std::basic_streambuf<char,std::char_traits><char> >::sputn

1044return xsputn(s, n);

(dbx) where

current thread: t@6

[1] std::basic_filebuf<char,std::char_traits><char> >::xsputn(0xfeb80810, 0x283

bc9, 0x10, 0x2, 0x0, 0x0), at 0xfeab5718

=>[2] std::basic_streambuf<char,std::char_traits><char> >::sputn(this = 0xfeb8081

0, s = 0x283bc8 "AAAThreadService", n = 16), line 1044 in "streambuf"

[3] std::operator<< <char,std::char_traits><char>,std::allocator<char> >(os = C

LASS, s = CLASS), line 549 in "ostream"

[4] AAADebug::LOG_TRACE(this = 0x2690e0, str1 = CLASS, str2 = CLASS), line 38

in "AAADebug.cpp"

[5] AAAThreadService::runThread(this = 0x2c6b88, inIndex = 3), line 136 in "AA

AThreadService.cpp"

[6] run(params = 0x268f10), line 117 in "AAAThreadService.cpp"

(dbx)

==================================

If anybody knows any any fix of this issue, please let me know. We are doubting there may be some issue in CC 5.5 for lpthread and iostream library.

Regards,

Nilanjan

[1817 byte] By [solaris_bitea] at [2007-11-27 9:05:38]
# 1
Did you use -mt compiler option or just -lpthread? Correct options for multithreaded binary are "-mt -lpthread" plus anything else you need to compiler/link.
MaximKartasheva at 2007-7-12 21:40:06 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2

Yes, we are using -lpthread -mt option, both.

We generally link the following library.

"-lpthread -lsocket -lnsl -mt -lc -lposix4".

In Logger, we print cout<<string><<"::"<<string><<endl;

Do you know, is there any conflict with std cout and std string class with pthread, in CC 5.5?

Thanks

solaris_bitea at 2007-7-12 21:40:06 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3

> Do you know, is there any conflict with std cout and std string class with pthread, in CC 5.5?

No, I don't... The only idea I have is to change order of options. man says: "If you are using POSIX threads, you must link with the options -mt -lpthread". Maybe placing -mt in front of -lpthread will help?

MaximKartasheva at 2007-7-12 21:40:06 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4
We are using "-mt -lpthread" this order now, and seems it fixes the issue.Thanks for your suggestion.
solaris_bitea at 2007-7-12 21:40:06 > top of Java-index,Development Tools,Solaris and Linux Development Tools...