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

sentry-native port requires zlib dependency on windows + problems on linux #39114

Closed
Patrix9999 opened this issue Jun 4, 2024 · 6 comments · Fixed by #39122
Closed

sentry-native port requires zlib dependency on windows + problems on linux #39114

Patrix9999 opened this issue Jun 4, 2024 · 6 comments · Fixed by #39122
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@Patrix9999
Copy link

Describe the bug
Hi!
I have two issues regarding the using of the sentry-native port.

  1. While trying to generate the cmake project build configuration while using sentry-native as vcpkg dependency, i'm getting this error:
1> [CMake] CMake Error at out/build/Windows-x86-Debug/vcpkg_installed/x86-windows/share/sentry/sentry_crashpad-targets.cmake:105 (set_target_properties):
1> [CMake]   The link interface of target "sentry_crashpad::zlib" contains:
1> [CMake] 
1> [CMake]     ZLIB::ZLIB

This problem might be solved by adding additional project dependency for zlib in vcpkg, however i'm not sure if this is correct behaviour, shouldn't sentry-native be a standalone port?

  1. On linux the cmake project generation & building it works fine, however while trying to run the app with dummy crash (assigning a nullptr after initialization of sentry) the crash raport doesn't gets send to the sentry backend.
[1717:1717:20240604,064748.491454:FATAL pthread_create_linux.cc:54] Check failed: next_pthread_create. dlsym: RTLD_NEXT used in code not dynamically loaded

Environment

  • OS: Windows (x86)/Linux (x64)

To Reproduce
Steps to reproduce the behavior (linux):

  1. Add VCPKG_ROOT path to locally installed vcpkg
    2, Generate a project via this command: cmake . --preset Linux-x64-Release
  2. Compile the project via this command cmake --build . --preset Linux-x64-Release
  3. Copy the crashpad-handler executable from out/build/Linux-x64-Release/vcpkg_installed/x64-linux/tools/sentry-native into /out/build/Linux-x64-Release

Expected behavior
The application should send a crashreport to a sentry backend on linux.
I'm not getting any issues while building & running my other project that depends on sentry-native as source dependency (crash report is being properly send to sentry backend).

Additional context
I'm using sentry-native 0.7.5 version (baseline: 67cc167)

And here's my ready to compile project that you can use to reproduce the issue
cmake-test.zip

You just need to set the DSN in main.cpp, and you're ready to build/test the project.

@dg0yt
Copy link
Contributor

dg0yt commented Jun 4, 2024

Linux: It seems that the issue had been raised in sentry-native before, but the proposed fixed was never forwarded to vcpkg:
getsentry/sentry-native#596
(My first impression is that it needs a patch to compile pthread_create_linux.cc only if BUILD_SHARED_LIBS.)

@JonLiu1993 JonLiu1993 added the category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) label Jun 4, 2024
@JonLiu1993
Copy link
Member

JonLiu1993 commented Jun 4, 2024

@Patrix9999, Thanks for posting this issue, regarding the first problem on Windows, I have not reproduced your problem locally. Here is my reproduction example.
CMakeLists:

cmake_minimum_required(VERSION 3.5)

project(test)

find_package(sentry CONFIG REQUIRED)

add_executable(test CMakeProject1.cpp)
target_link_libraries(test PRIVATE sentry::sentry)

CMakeProject1.cpp:

=#include <stdio.h>
#include <sentry.h>

int main()
{
    printf("%s\n", "HELLO WORLD");
    return 0;
}

Config:

1> CMake generation started for configuration: 'x64-Debug'.
1> Command line: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Visual Studio 17 2022" -A x64  -DCMAKE_CONFIGURATION_TYPES:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\test\source\repos\CMakeProject1\out\install\x64-Debug"  -DCMAKE_TOOLCHAIN_FILE=F:/Feature-test/vcpkg/scripts/buildsystems/vcpkg.cmake "C:\Users\test\source\repos\CMakeProject1" 2>&1"
1> Working directory: C:\Users\test\source\repos\CMakeProject1\out\build\x64-Debug
1> [CMake] -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
1> [CMake] -- The C compiler identification is MSVC 19.39.33523.0
1> [CMake] -- The CXX compiler identification is MSVC 19.39.33523.0
1> [CMake] -- Detecting C compiler ABI info
1> [CMake] -- Detecting C compiler ABI info - done
1> [CMake] -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting C compile features
1> [CMake] -- Detecting C compile features - done
1> [CMake] -- Detecting CXX compiler ABI info
1> [CMake] -- Detecting CXX compiler ABI info - done
1> [CMake] -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting CXX compile features
1> [CMake] -- Detecting CXX compile features - done
1> [CMake] -- Configuring done (7.3s)
1> [CMake] -- Generating done (0.1s)
1> [CMake] -- Build files have been written to: C:/Users/test/source/repos/CMakeProject1/out/build/x64-debug
1> Extracted CMake variables.
1> Extracted source files and headers.
1> Extracted code model.
1> Extracted toolchain configurations.
1> Extracted includes paths.
1> CMake generation finished.

@JonLiu1993 JonLiu1993 added category:port-bug The issue is with a library, which is something the port should already support and removed category:vcpkg-bug The issue is with the vcpkg system (including helper scripts in `scripts/cmake/`) labels Jun 4, 2024
@Patrix9999
Copy link
Author

@Patrix9999, Thanks for posting this issue, regarding the first problem on Windows, I have not reproduced your problem locally. Here is my reproduction example. CMakeLists:

cmake_minimum_required(VERSION 3.5)

project(test)

find_package(sentry CONFIG REQUIRED)

add_executable(test CMakeProject1.cpp)
target_link_libraries(test PRIVATE sentry::sentry)

CMakeProject1.cpp:

=#include <stdio.h>
#include <sentry.h>

int main()
{
    printf("%s\n", "HELLO WORLD");
    return 0;
}

Config:

1> CMake generation started for configuration: 'x64-Debug'.
1> Command line: "C:\WINDOWS\system32\cmd.exe" /c "%SYSTEMROOT%\System32\chcp.com 65001 >NUL && "C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\2022\COMMUNITY\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\CMAKE\CMake\bin\cmake.exe"  -G "Visual Studio 17 2022" -A x64  -DCMAKE_CONFIGURATION_TYPES:STRING="Debug" -DCMAKE_INSTALL_PREFIX:PATH="C:\Users\test\source\repos\CMakeProject1\out\install\x64-Debug"  -DCMAKE_TOOLCHAIN_FILE=F:/Feature-test/vcpkg/scripts/buildsystems/vcpkg.cmake "C:\Users\test\source\repos\CMakeProject1" 2>&1"
1> Working directory: C:\Users\test\source\repos\CMakeProject1\out\build\x64-Debug
1> [CMake] -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
1> [CMake] -- The C compiler identification is MSVC 19.39.33523.0
1> [CMake] -- The CXX compiler identification is MSVC 19.39.33523.0
1> [CMake] -- Detecting C compiler ABI info
1> [CMake] -- Detecting C compiler ABI info - done
1> [CMake] -- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting C compile features
1> [CMake] -- Detecting C compile features - done
1> [CMake] -- Detecting CXX compiler ABI info
1> [CMake] -- Detecting CXX compiler ABI info - done
1> [CMake] -- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.39.33519/bin/Hostx64/x64/cl.exe - skipped
1> [CMake] -- Detecting CXX compile features
1> [CMake] -- Detecting CXX compile features - done
1> [CMake] -- Configuring done (7.3s)
1> [CMake] -- Generating done (0.1s)
1> [CMake] -- Build files have been written to: C:/Users/test/source/repos/CMakeProject1/out/build/x64-debug
1> Extracted CMake variables.
1> Extracted source files and headers.
1> Extracted code model.
1> Extracted toolchain configurations.
1> Extracted includes paths.
1> CMake generation finished.

I'll try to come up with reproducable sample project that has this issue.

@Patrix9999
Copy link
Author

Patrix9999 commented Jun 5, 2024

From my initial tests i can conclude that this missing ZLIB::ZLIB issue (windows-only) occurs when we will be using a triplet that statically compiles, everything works fine when the sentry gets compiled as dynamic library.

Here's a very simple project that has this issue (i've removed all of the fancy configuration files, to present the issue in a simplest way)
test-app.zip

The problem occurs during generation stage while using triplet that statically compiles the code, e.g: x64-windows-static.

How to generate/build the project:

  • create build subfolder inside the project structure
  • cd into build directory
  • run cmake .. -DCMAKE_TOOLCHAIN_FILE=ABSOLUTE_PATH_TO_VCPKG_ROOT_DIR/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static

Such project won't be generated correctly, and it will produce the following error:

CMake Error at build/vcpkg_installed/x64-windows-static/share/sentry/sentry_crashpad-targets.cmake:105 (set_target_prope          rties):
  The link interface of target "sentry_crashpad::zlib" contains:

    ZLIB::ZLIB

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

The issue can be avoided by compiling the vcpkg ports as dynamic libraries, or by adding additional zlib port dependency, but i still think that this is unintended behaviour, mostly because accoring to vcpkg, port should be self contained, correct me if i'm wrong (maybe i'm missing something out).

@JonLiu1993
Copy link
Member

@Patrix9999, thanks for the repro project, I have reproduced this Windows bug and fixed it, I will submit it in my PR.

@Patrix9999
Copy link
Author

No problem, i'm just glad that i was able to help you to find a solution to this problem quicker (i would personally try to open a pull request, but unfortunately i didn't have time to investigate what might be the issue).
Good job 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants