Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
SEGFAULT when running statically compiled CAF application #919
Comments
|
Hi, I'd like to reproduce this. So far I got a Docker image of Debian 10 with the same g++ version. I built CAF with the same config parameters you used, only adjusting the prefix and installed the library. With that setup I tried a few examples and they built and executed without problems ( Do you have further information on how to reproduce this? |
|
Thank you. @josephnoir There are more details. This is the code: This is the CMakeLists.txt CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -std=c++11 -g") SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++") INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/../../build/caf/include) |
|
Ok, was able to reproduce this. I adjusted the CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)
PROJECT(CAF_TEST)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -std=c++11 -g")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static -static-libgcc -static-libstdc++")
if(NOT CAF_ROOT_DIR)
set(CAF_ROOT_DIR "/caf-static/")
endif()
find_package(CAF COMPONENTS core)
if (CAF_FOUND)
include_directories(${CAF_INCLUDE_DIRS})
else ()
message(FATAL_ERROR "Could not find CAF.")
endif()
add_executable(main main.cpp)
target_link_libraries(main ${CAF_LIBRARY_CORE} pthread)Long story short. I get the same behavior. The key are the |
|
A simpler example to reproduce the error is the following program. #include <thread>
#include <iostream>
int main() {
std::cout << "Thread id: " << std::this_thread::get_id() << std::endl;
}I can compile it (g++ command is below), but it fails to execute as well. Linking pthread statically seems to be a known problem, but the whole archive options supposedly addresses it. $ g++ -m64 -std=c++11 -static -o thread-test thread-test.cpp -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archiveThe stack trace is the same for the CAF example--provided you build everything with debug symbols.
Edit:
|
|
Hm. The minimal example that just calls $ g++ -D_GLIBCXX_GTHREAD_USE_WEAK=0 -m64 -std=c++11 -static -static-libgcc -static-libstdc++ -o thread-test thread-test.cpp -pthread -Wl,--whole-archive -lpthread -Wl,--no-whole-archive |
|
@hanyizhao this might be related to zeek/zeek#610, which boiled down to static builds not settings |
|
@Neverlord Still have this problem. |
|
Ok, thanks for checking. We'll probably add Debian to our CI soon. Once we have that up and running I'll add static builds to the build matrix to reproduce (and fix) this. |
|
The static build works fine in our CI on Debian 10 / GCC 8.3 without any extra flags: https://jenkins.inet.haw-hamburg.de/blue/rest/organizations/jenkins/pipelines/CAF/pipelines/actor-framework/branches/master/runs/491/nodes/125/log/?start=0 |
I use Debian 10 with gcc 8.3.0
I build the core library:
./configure --prefix=/home/hanyizhao/build/caf --build-type=Release --build-static-only --core-only --static-runtime
But when I tested my program, it crashed.
`Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Program received signal SIGSEGV, Segmentation fault.
0x0000000000000000 in ?? ()
(gdb) bt
#0 0x0000000000000000 in ?? ()
#1 0x0000000000481a58 in caf::logger::thread_local_aid(unsigned long) ()
#2 0x00000000004a47ec in caf::scheduled_actor::launch(caf::execution_unit*, bool, bool) ()
#3 0x000000000041c2ec in caf::actor_system::actor_system(caf::actor_system_config&) ()
#4 0x000000000040c8dd in main ()
`