Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
Languages and Scripting
Showing results for 
Search instead for 
Did you mean: 

Segmentation fault, dlopen ,aCC -AA -Ae

Go to solution
Occasional Contributor

Segmentation fault, dlopen ,aCC -AA -Ae

machime platform:
ia64 HP-UX B.11.23

when program 'A' use dlopen function to load library 'B', program 'A' may crash

scene description :
program 'A' use dlopen to load dynamic library "B', and "A" and "B" is correct in syntax and

logic,and 'A' is compiled by C language ,and 'B' is complied by C++ language

'A' compile parameter is:
aCC -o A.out -Ae -g +DD64 -mt -dynamic -ldl -lpthread

'B' compile parameter is:
aCC -o -AA -b -mt -Wl,+s -Wl,+vnocompatwarnings +DD64 +Olit=all -Wl,-hsqlca,+allowdups

-w -lunwind -lCsup -lstd_v2

'A" used (aCC -Ae),"B" used (aCC-AA)

print stack as below:

Program terminated with signal 11, Segmentation fault.
SEGV_MAPERR - Address not mapped to object

#0 0xc0000000000e7560:0 in pthread_mutex_destroy+0xc0 ()
from /usr/lib/hpux64/
(gdb) where
#0 0xc0000000000e7560:0 in pthread_mutex_destroy+0xc0 ()
from /usr/lib/hpux64/
#1 0xc000000000357de0:0 in __thread_mutex_free+0xc0 ()
from /usr/lib/hpux64/
#2 0xc00000000233f370:0 in _HPMutexWrapper::~_HPMutexWrapper()+0xd0 ()
from /usr/lib/hpux64/
#3 0xc000000006eda1e0:0 in std::basic_streambuf

>::~basic_streambuf () at EIClass.cpp:1
#4 0xc000000006eb6980:0 in


>::~basic_stringstream ()
at /opt/aCC/include_std/sstream:74
#5 0xc000000006ec8690:0 in EIClass::GetColVal () at EIClass.cpp:1441 //-----------------------> user


This problem happened in EIClass::GetColVal () return function,
snippet displayed as below

int EIClass::GetColVal (){


return 0; //-----------------------> coredump happen

Dennis Handly
Acclaimed Contributor

Re: Segmentation fault, dlopen ,aCC -AA -Ae

>aCC -Ae -g +DD64 -mt -dynamic -ldl -lpthread

You should NOT be using "aCC -Ae". Instead use cc. You don't need -lpthread since you have -mt. Also you shouldn't use -dynamic since it is the default.

>aCC -AA -b -mt -Wl,+s -Wl,+vnocompatwarnings +DD64 +Olit=all -Wl,-hsqlca,+allowdups

+Olit=all is the default, you don't need this.
-Wl,-hsqlca,+allowdups should be split into two ld options: -Wl,-hsqlca -Wl,+allowdups
Why do you have the latter? Any duplicates violate the ODR rule and are illegal.

>-lunwind -lCsup -lstd_v2

This is illegal and doesn't match what's documented for plugins.
The order is: -lstd_v2 -lCsup -lunwind -lm

This may be the cause. Also have you compiled everything with -mt?

You shouldn't use -w but suppress individual warnings with +Wnnnn.

Occasional Contributor

Re: Segmentation fault, dlopen ,aCC -AA -Ae

thanks, i will try it.
Occasional Contributor

Re: Segmentation fault, dlopen ,aCC -AA -Ae

hello Dennis Handly:
I have a question.

Does it have any problem when a 'C'program call 'C++' shared library with dlopen,
can you give me some suggestions or show me more relalted information, thank you very much.
Dennis Handly
Acclaimed Contributor

Re: Segmentation fault, dlopen ,aCC -AA -Ae

>Does it have any problem when a C program call aC++ shared library with dlopen, can you give me some suggestions or show me more related information.

It shouldn't. The URL I provided above shows how to link an aC++ shlib for a plugin.