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

pthread_create_linux.cc:53 - Check failed: next_pthread_Create. dlsym: RTLD_NEXT used in code not dynamically loaded #596

Closed
2 tasks
JasonDictos opened this issue Oct 15, 2021 · 2 comments

Comments

@JasonDictos
Copy link

JasonDictos commented Oct 15, 2021

Description

A combination of how I build my statically linked application, and the vcpkg port of sentry-native (with SENTRY_BACKEND set to 'crashpad') causes this error to log when I attempt to initialize sentry (we are just trying it out atm):

[786206:786206:20211015,005853.690856:FATAL pthread_create_linux.cc:53] Check failed: next_pthread_create. dlsym: RTLD_NEXT used in code not dynamically loaded

When does the problem happen

  • During build
  • [x ] During run-time
  • When capturing a hard crash

Environment

Using portfile from vcpkg, configured with static linkages to the crt, and the runtime
Port file

if(NOT VCPKG_TARGET_IS_OSX)
    vcpkg_fail_port_install(ON_ARCH "arm" "arm64" ON_TARGET "UWP")
endif()

vcpkg_download_distfile(ARCHIVE
    URLS "https://github.com/getsentry/sentry-native/releases/download/0.4.12/sentry-native.zip"
    FILENAME "sentry-native-0.4.12.zip"
    SHA512 15da4407ed5e2c8d5e56e497ccc6006b29235aef6b3a81e034c93443e20a7cfdf95d55e31b88e552c55e824eb15d6f7fafe988c453a5a6f36fe45136d7268b19
)

vcpkg_extract_source_archive_ex(
    OUT_SOURCE_PATH SOURCE_PATH
    ARCHIVE ${ARCHIVE}
    NO_REMOVE_ONE_LEVEL
    PATCHES
        fix-warningC5105.patch
        fix-config-cmake.patch
        use-zlib-target.patch
)

# Crashpad is the external form of a crash handler, reccomended for all platforms
# (vs breakpad which is in process)
set(SENTRY_BACKEND "crashpad")

vcpkg_cmake_configure(
    SOURCE_PATH ${SOURCE_PATH}
    OPTIONS
        -DSENTRY_BUILD_TESTS=OFF
        -DSENTRY_BUILD_EXAMPLES=OFF
        -DSENTRY_BACKEND=${SENTRY_BACKEND}
        -DCRASHPAD_ZLIB_SYSTEM=ON
)

vcpkg_cmake_install()

vcpkg_copy_pdbs()

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/sentry)

if (SENTRY_BACKEND STREQUAL "crashpad")
    vcpkg_copy_tools(
        TOOL_NAMES crashpad_handler
        AUTO_CLEAN
    )
endif()

if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
    file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()

file(
    INSTALL ${SOURCE_PATH}/LICENSE
    DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}
    RENAME copyright
)

Triplet

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE static)
set(VCPKG_LIBRARY_LINKAGE static)
set(VCPKG_CMAKE_SYSTEM_NAME Linux)

Ubuntu 21.04 x64 compiled with gcc-11.0.1:

Using built-in specs.
COLLECT_GCC=gcc-11
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11-20210417-1ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-pzZXCn/gcc-11-11-20210417/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-pzZXCn/gcc-11-11-20210417/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.0.1 20210417 (experimental) [master revision c1c86ab96c2:b6fb0ccbb48:8ae884c09fbba91e9cec391290ee4a2859e7ff41] (Ubuntu 11-20210417-1ubuntu1) 

Relevant compiler flags:

 -fPIC -fPIE -Wunused-function -ffunction-sections -Wno-free-nonheap-object -Wno-switch -fPIC -fPIE -Wunused-function -ffunction-sections -Wno-free-nonheap-object -Wno-switch -fPIC -fPIE -Wunused-function -ffunction-sections -Wno-free-nonheap-object -Wno-switch -fPIC -fPIE -Wunused-function -ffunction-sections -Wno-free-nonheap-object -Wno-switch -g -g -O0 -fno-inline -g -O0 -fno-inline -g -O0 -fno-inline -g -O0 -fno-inline -fcoroutines -pthread -std=gnu++2a -Winvalid-pch -x c++-header -include 

Relevant linker flags and libraries used with my application:

 -fPIC 
 -fPIE -Wunused-function 
 -ffunction-sections -Wno-free-nonheap-object 
 -Wno-switch -g 
 -g -O0 
 -fno-inline  
 libreproc++.a  
 libreproc.a  
 libboost_random.a  
 libicuuc.a  
 libicudata.a  
 libicui18n.a  
 libicuio.a  
 libefsw.a  
 libsentry.a  
 libcurl-d.a  
 libz.a  
 -Wl,-E,--build-id=sha1  
 -lrt  
 libcrashpad_client.a  
 libcrashpad_util.a  
 libssl.a  
 libcrypto.a  
 -lpthread  
 libcrashpad_compat.a  
 -ldl  
 libmini_chromium.a  
 -lpthread

cmake version 3.21.3

Steps To Reproduce

No idea, first time trying to use sentry.

Log output
[sentry] INFO using database path ************************************
[sentry] DEBUG starting transport
[sentry] DEBUG starting background worker thread
[sentry] DEBUG starting backend
[sentry] DEBUG starting crashpad backend with handler /crashpad_handler"
[sentry] DEBUG background worker thread started
[sentry] DEBUG using minidump url "
"
[823917:823917:20211015,011400.875686:FATAL pthread_create_linux.cc:53] Check failed: next_pthread_create. dlsym: RTLD_NEXT used in code not dynamically loaded

@Swatinem
Copy link
Member

The relevant code is here:
https://github.com/getsentry/crashpad/blob/2743206d0a52cf11730a14ca139113c679e24edd/client/pthread_create_linux.cc#L52-L54
It looks like crashpad still expects that pthread is linked dynamically, when using that functionality.

The crashpad docs say this:
https://github.com/getsentry/crashpad/blob/cd675cfb9655911e5fc8e0b80bd9c502ef24f95a/client/crashpad_client.h#L163-L166

Which means that this snipped it not linked to your application itself, however it is linked to the crashpad_handler by default.

I see you do apply some patches as part of the vcpkg build, so you might as well remove this cmake block in another patch:

https://github.com/getsentry/crashpad/blob/5cf3032b2281cf0928acc8bccf69f91ccf26b939/handler/CMakeLists.txt#L91-L95

That will remove the offending source file from the crashpad_handler, and should solve your problem if I’m correct.

@JasonDictos
Copy link
Author

That indeed worked, much obliged

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