Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A segfault occurs when executing the executable file which bound the log4cplus static lib(log4cplus.a) #512

Open
XieChengzhi1998 opened this issue Jun 16, 2021 · 4 comments
Assignees

Comments

@XieChengzhi1998
Copy link

XieChengzhi1998 commented Jun 16, 2021

Hello,
When I compiling log4cplus, I only generated static library bfiles, the configure option i used was
./configure --prefix=/home/log4cplus --enable-static --disable-shared
After compiling, i got four files: liblog4cplus.a, liblog4cplus.la , liblog4cplusU.a, liblog4cplusU.la

Then I successfully performed static compilation through these library files, but a segmentation error was reported during the execution of the program. The error message is
XXX[55809]: segfault at fffffffffffffff8 ip 00007f60bf23b2bb sp 00007ffde8c6cce0 error 5 in libstdc++.so.6.0.28 [7f60bf157000+1bd000]

And when I dynamically compile log4cplus to generate .so files, my program can be executed correctly. I want to know how to solve this segfault and successfully compile log4cplus staticalto my program

My linux version is Red Hat 4.8.5-4, the log4cplus version is 2.0.5

@wilx wilx self-assigned this Jun 16, 2021
@wilx
Copy link
Contributor

wilx commented Jun 16, 2021

I am afraind this is not enough information to go on. Can you start it under GDB and provide a call stack of the failure?

@XieChengzhi1998
Copy link
Author

XieChengzhi1998 commented Jun 16, 2021

I am afraind this is not enough information to go on. Can you start it under GDB and provide a call stack of the failure?

#0  std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string (this=0x678920, __str=...)
    at /home/shenghui/dien_ALI/dien_proxy/third_party/gcc-10.1.0/gccbuild/x86_64-pc-linux-gnu/libstdc++-v3/include/bits/basic_string.tcc:615
#1  0x00007ffff7ba1ba6 in log4cplus::Appender::Appender() () from /home/xiechengzhi.xcz/venus-diagnosis/cpp/build/libs/venus_engine/libvenus_engine.so.1
#2  0x00007ffff7b7d78b in log4cplus::FileAppenderBase::FileAppenderBase(std::string const&, std::_Ios_Openmode, bool, bool) ()
   from /home/xiechengzhi.xcz/venus-diagnosis/cpp/build/libs/venus_engine/libvenus_engine.so.1
#3  0x00007ffff7b8478e in log4cplus::FileAppender::FileAppender(std::string const&, std::_Ios_Openmode, bool, bool) ()
   from /home/xiechengzhi.xcz/venus-diagnosis/cpp/build/libs/venus_engine/libvenus_engine.so.1
#4  0x00007ffff7b848a8 in log4cplus::RollingFileAppender::RollingFileAppender(std::string const&, long, int, bool, bool) ()
   from /home/xiechengzhi.xcz/venus-diagnosis/cpp/build/libs/venus_engine/libvenus_engine.so.1
#5  0x00007ffff7b62fd9 in venus::VenusLog::VenusLog (this=<optimized out>) at /home/xiechengzhi.xcz/venus-diagnosis/cpp/libs/venus_engine/src/logger/logger.cpp:16
#6  0x00007ffff7b633e1 in __static_initialization_and_destruction_0 (__priority=65535, __initialize_p=1) at /home/xiechengzhi.xcz/venus-diagnosis/cpp/libs/venus_engine/src/logger/logger.cpp:40
#7  _GLOBAL__sub_I_logger.cpp(void) () at /home/xiechengzhi.xcz/venus-diagnosis/cpp/libs/venus_engine/src/logger/logger.cpp:42
#8  0x00007ffff7dea943 in _dl_init_internal () from /lib64/ld-linux-x86-64.so.2
#9  0x00007ffff7ddc19a in _dl_start_user () from /lib64/ld-linux-x86-64.so.2
#10 0x0000000000000001 in ?? ()
#11 0x00007fffffffe62b in ?? ()
#12 0x0000000000000000 in ?? ()

Thanks for your reply.
Is this the call stack information you need? I printed it through the traceback command under gdb

@wilx
Copy link
Contributor

wilx commented Jun 16, 2021

This is static initialization order fiasco. Your library is trying to use log4cplus before some static members have been initialized.

@XieChengzhi1998
Copy link
Author

This is static initialization order fiasco. Your library is trying to use log4cplus before some static members have been initialized.

Thank you very much for your answer, I understand what you mean. I am trying to solve this problem by changing the library link order in the makefile so that the log4cplus library is linked first. But this problem still existed. I am wondering that are there any simpler approches to solve this problem or i have to change the source code of my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants