Operating System - HP-UX
1752662 Members
5201 Online
108788 Solutions
New Discussion юеВ

-mt linker flag causing crash

 
Sruthi P
Occasional Contributor

-mt linker flag causing crash

I am porting our application to 64-bit on a HP-ia64 11.23 machine.
We use log4cplus for logging.

My application crashes at runtime and the gdb stack trace points to the following line of code.
APPLOGGER_INITIALIZE("logging.properties");
where
#define APPLOGGER_INITIALIZE(filename) log4cplus::PropertyConfigurator::doConfigure(LOG4CPLUS_STRING_TO_TSTRING(filename));

The stack trace is included below.
Program terminated with signal 11, Segmentation fault.
SEGV_MAPERR - Address not mapped to object
#0 0xc0000000000ec090:0 in pthread_mutex_lock+0x610 ()
from /usr/lib/hpux64/libpthread.so.1
(gdb) where
#0 0xc0000000000ec090:0 in pthread_mutex_lock+0x610 ()
from /usr/lib/hpux64/libpthread.so.1
#1 0xc000000000359fb0:0 in __thread_mutex_lock+0xb0 ()
from /usr/lib/hpux64/libc.so.1
#2 0xc000000002046be0:0 in _HPMutexWrapper::lock(void*)+0x80 ()
from /usr/lib/hpux64/libstd_v2.so.1
#3 0xc00000000211f160:0 in std::basic_istream >::read(char*,long,int,int)+0xa0 () from /usr/lib/hpux64/libstd_v2.so.1
#4 0xc0000001136db9f0:0 in std::basic_istream >::getline () at /opt/aCC/include_std/istream:235
#5 0xc0000001136debe0:0 in log4cplus::helpers::Properties::init ()
at property.cxx:104
#6 0xc0000001136dfd40:0 in log4cplus::helpers::Properties::Properties ()
at property.cxx:90
#7 0xc0000001136e01d0:0 in log4cplus::helpers::Properties::Properties(std::basic_string,std::allocator > const&)+0x40 ()
at property.cxx:0
#8 0xc0000001135e96a0:0 in log4cplus::PropertyConfigurator::PropertyConfigurator () at configurator.cxx:204
#9 0xc0000001135ea740:0 in log4cplus::PropertyConfigurator::PropertyConfigurator(std::basic_string,std::allocator > const&,log4cplus::Hierarchy&)+0x50 () at configurator.cxx:0
#10 0xc0000001135ec7a0:0 in log4cplus::PropertyConfigurator::doConfigure ()

The linker flags I use to build my application are
aCC -Wl,-N -Wl,+s -Wl,+b,/usr/lib/hpux64:. -Wl,-Brestricted -AA +DD64 -mt

However if I remove the -mt flag I do not get the error.
Can anyone tell me why I get the error if I use the -mt linker flag.

Any help is very much appreciated.
Thanks
Sruthi
6 REPLIES 6
Dennis Handly
Acclaimed Contributor

Re: -mt linker flag causing crash

Is your application threaded? If not, don't use -mt.

If you link against libpthread, every object must be compiled with -mt.
Your stack trace implies that you have compiled some code referencing std::basic_istream without -mt. I.e. when you constructed it.

If your lib needs to be used by applications that are or aren't threaded, compile with -mt but don't link with -mt.

Sruthi P
Occasional Contributor

Re: -mt linker flag causing crash

Hi Dennis,

Thanks for the quick response.

Yes my application is multithreaded.
I realized that I had not compiled log4cplus with the -mt flag. So I recompiled log4cplus with -mt and rebuilt my application with log4cplus but my application still crashes when i use the -mt linker flag and the gdb stacktrace is the same as previous.
V├бclav Haisman
New Member

Re: -mt linker flag causing crash

Hi, I am developing log4cplus. What version of log4cplus are you using? Is it possible for you to reduce "logging.properties" to the smallest possible file that still reproduces the problem and post it here?

I do not have access to an IA64/HP-UX machine but I could at least take a look at the source given the call stack and line numbers and version of the source.
V├бclav Haisman
New Member

Re: -mt linker flag causing crash

Another idea, what configure script flags have you used? Since your application is threaded, have you configured log4cplus with --enable-threads=yes, too?
Dennis Handly
Acclaimed Contributor

Re: -mt linker flag causing crash

>rebuilt my application with log4cplus but my application still crashes when I use the -mt linker flag and the gdb stacktrace is the same as previous.

Have you checked EVERY object, archive and shared lib in your application for -mt? Even other third party libs.

Try footprints(1) on your application.

Are you on a thread stack or in the main thread?
Sruthi P
Occasional Contributor

Re: -mt linker flag causing crash

The problem has been fixed.

@Dennis
I recompiled all the open source libraries with -mt compilation flag, checked if the 3rd party libraries were compiled with -mt...they were.

@Vaclay
We use log4cplus version 1.0.2.
I used --enable-pthread flag while compiling log4cplus. I noticed this did not change the CFLAGS, CXXFLAGS or the compiler options though.

One or both of these steps fixed the problem. Once I finish this task I will isolate them check which one actually worked post it here and close the thread.

Thanks for the help provided in fixing the problem

Regards
Sruthi