Here’s the code:
foo.h
extern "C" {
int sdq_init_connector(const SSchar* path);
}
foo.cxx
int sdq_init_connector(const SSchar* path)
{
Logger log(LOG_DEBUG, "sdq_init_connector");
/*
here goes some not so relevant code
*/
log.write("Here be dragons");
return 0;
}
And there is Logger class, that is being used in foo, nothing interesting, constructor(char * message), destructor() and write(char * message).
Problem summary:
When I call libfoo.so from test appliance it work flawlessly but when it is getting called from production system after function sdq_init_connector return it SEGFAULTs backtrace below
#10 <signal handler called>
#11 0x583d7fee in Node::~Node() () from /opt/siebel/sba81/siebsrvr/mw/lib/libtl.so
#12 0x583de09a in Logger::~Logger() () from /opt/siebel/sba81/siebsrvr/mw/lib/libtl.so
#13 0x6c86e001 in sdq_init_connector () from /opt/siebel/sba81/siebsrvr/lib/libfoo.so
Note the #12 there is another library with same object name. Why is destructor from some foreign library called for my internal object?
The signatures of destructors for Logger object were same indeed.
How it was:
How it now:
I’ve added namespace to my library, and it solved this problem.