diff --git a/CHANGELOG.md b/CHANGELOG.md index 0550d4724..dcaaf1ebf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,21 +1,30 @@ # Changelog -## Unreleased +## 0.7.0 + +**Breaking changes**: + +- Make `crashpad` the default backend for Linux. ([#927](https://github.com/getsentry/sentry-native/pull/927)) +- Remove build option `SENTRY_CRASHPAD_SYSTEM`. ([#928](https://github.com/getsentry/sentry-native/pull/928)) **Fixes**: -- Maintain crashpad client instance during Native SDK lifecycle. ([#910](https://github.com/getsentry/sentry-native/pull/910)) +- Maintain `crashpad` client instance during Native SDK lifecycle. ([#910](https://github.com/getsentry/sentry-native/pull/910)) +- Specify correct dependencies for CMake client projects using a system-provided breakpad. ([#926](https://github.com/getsentry/sentry-native/pull/926)) +- Correct the Windows header include used by `sentry.h`, which fixes the build of [Swift bindings](https://github.com/thebrowsercompany/swift-sentry). ([#935](https://github.com/getsentry/sentry-native/pull/935)) **Internal**: - Updated `crashpad` to 2023-11-24. ([#912](https://github.com/getsentry/sentry-native/pull/912), [crashpad#91](https://github.com/getsentry/crashpad/pull/91)) - Fixing `crashpad` build for Windows on ARM64. ([#919](https://github.com/getsentry/sentry-native/pull/919), [crashpad#90](https://github.com/getsentry/crashpad/pull/90), [crashpad#92](https://github.com/getsentry/crashpad/pull/92), [crashpad#93](https://github.com/getsentry/crashpad/pull/93), [crashpad#94](https://github.com/getsentry/crashpad/pull/94)) - +- Remove options memory leak during consent setting. ([#922](https://github.com/getsentry/sentry-native/pull/922)) + **Thank you**: Features, fixes and improvements in this release have been contributed by: - [@compnerd](https://github.com/compnerd) +- [@stima](https://github.com/stima) ## 0.6.7 diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ec677899..8e460cded 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,11 +26,11 @@ if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) endif() if(NOT CMAKE_C_STANDARD) - set(CMAKE_C_STANDARD 11) + set(CMAKE_C_STANDARD 11) endif() if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD 17) endif() include(GNUInstallDirs) @@ -96,7 +96,7 @@ else() endif() set(SENTRY_TRANSPORT ${SENTRY_DEFAULT_TRANSPORT} CACHE STRING - "The HTTP transport that sentry uses to submit events to the sentry server, can be either 'none', 'curl' or 'winhttp' on windows.") + "The HTTP transport that sentry uses to submit events to the sentry server, can be either 'none', 'curl' or 'winhttp' on windows.") if(SENTRY_TRANSPORT STREQUAL "winhttp") set(SENTRY_TRANSPORT_WINHTTP TRUE) @@ -125,10 +125,8 @@ option(SENTRY_ENABLE_INSTALL "Enable sentry installation" "${SENTRY_MAIN_PROJECT if(MSVC AND CMAKE_GENERATOR_TOOLSET MATCHES "_xp$") message(WARNING "Crashpad is not supported for MSVC with XP toolset. Default backend was switched to 'breakpad'") set(SENTRY_DEFAULT_BACKEND "breakpad") -elseif((APPLE AND NOT IOS) OR WIN32) +elseif((APPLE AND NOT IOS) OR WIN32 OR LINUX) set(SENTRY_DEFAULT_BACKEND "crashpad") -elseif(LINUX) - set(SENTRY_DEFAULT_BACKEND "breakpad") else() set(SENTRY_DEFAULT_BACKEND "inproc") endif() @@ -367,11 +365,11 @@ endif() # handle platform libraries if(ANDROID) - set(_SENTRY_PLATFORM_LIBS "dl" "log") + set(_SENTRY_PLATFORM_LIBS "dl" "log") elseif(LINUX) - set(_SENTRY_PLATFORM_LIBS "dl" "rt") + set(_SENTRY_PLATFORM_LIBS "dl" "rt") elseif(WIN32) - set(_SENTRY_PLATFORM_LIBS "dbghelp" "shlwapi" "version") + set(_SENTRY_PLATFORM_LIBS "dbghelp" "shlwapi" "version") endif() if(SENTRY_TRANSPORT_WINHTTP) @@ -385,9 +383,9 @@ endif() # apply platform libraries to sentry library if(SENTRY_LIBRARY_TYPE STREQUAL "STATIC") - target_link_libraries(sentry PUBLIC ${_SENTRY_PLATFORM_LIBS}) + target_link_libraries(sentry PUBLIC ${_SENTRY_PLATFORM_LIBS}) else() - target_link_libraries(sentry PRIVATE ${_SENTRY_PLATFORM_LIBS}) + target_link_libraries(sentry PRIVATE ${_SENTRY_PLATFORM_LIBS}) endif() # suppress some errors and warnings for MinGW target @@ -415,74 +413,68 @@ if(SENTRY_WITH_LIBUNWINDSTACK) endif() if(SENTRY_BACKEND_CRASHPAD) - option(SENTRY_CRASHPAD_SYSTEM "Use system crashpad" OFF) - if(SENTRY_CRASHPAD_SYSTEM) - find_package(crashpad REQUIRED) - target_link_libraries(sentry PUBLIC crashpad::client) + # FIXME: required for cmake 3.12 and lower: + # - NEW behavior lets normal variable override option + cmake_policy(SET CMP0077 NEW) + if(SENTRY_BUILD_SHARED_LIBS) + set(CRASHPAD_ENABLE_INSTALL OFF CACHE BOOL "Enable crashpad installation" FORCE) else() - # FIXME: required for cmake 3.12 and lower: - # - NEW behavior lets normal variable override option - cmake_policy(SET CMP0077 NEW) - if(SENTRY_BUILD_SHARED_LIBS) - set(CRASHPAD_ENABLE_INSTALL OFF CACHE BOOL "Enable crashpad installation" FORCE) - else() - set(CRASHPAD_ENABLE_INSTALL ON CACHE BOOL "Enable crashpad installation" FORCE) - endif() - add_subdirectory(external/crashpad crashpad_build) + set(CRASHPAD_ENABLE_INSTALL ON CACHE BOOL "Enable crashpad installation" FORCE) + endif() + add_subdirectory(external/crashpad crashpad_build) - if(CRASHPAD_WER_ENABLED) - add_dependencies(sentry crashpad::wer) - endif() + if(CRASHPAD_WER_ENABLED) + add_dependencies(sentry crashpad::wer) + endif() - # set static runtime if enabled - if(SENTRY_BUILD_RUNTIMESTATIC AND MSVC) - set_property(TARGET crashpad_client PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - set_property(TARGET crashpad_compat PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - set_property(TARGET crashpad_getopt PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - set_property(TARGET crashpad_handler PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - set_property(TARGET crashpad_handler_lib PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - set_property(TARGET crashpad_minidump PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - set_property(TARGET crashpad_snapshot PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - set_property(TARGET crashpad_tools PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - set_property(TARGET crashpad_util PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - if(CRASHPAD_WER_ENABLED) - set_property(TARGET crashpad_wer PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - endif() - set_property(TARGET crashpad_zlib PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") - set_property(TARGET mini_chromium PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + # set static runtime if enabled + if(SENTRY_BUILD_RUNTIMESTATIC AND MSVC) + set_property(TARGET crashpad_client PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + set_property(TARGET crashpad_compat PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + set_property(TARGET crashpad_getopt PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + set_property(TARGET crashpad_handler PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + set_property(TARGET crashpad_handler_lib PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + set_property(TARGET crashpad_minidump PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + set_property(TARGET crashpad_snapshot PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + set_property(TARGET crashpad_tools PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + set_property(TARGET crashpad_util PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + if(CRASHPAD_WER_ENABLED) + set_property(TARGET crashpad_wer PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") endif() + set_property(TARGET crashpad_zlib PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + set_property(TARGET mini_chromium PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") + endif() - if(DEFINED SENTRY_FOLDER) - set_target_properties(crashpad_client PROPERTIES FOLDER ${SENTRY_FOLDER}) - set_target_properties(crashpad_compat PROPERTIES FOLDER ${SENTRY_FOLDER}) - set_target_properties(crashpad_getopt PROPERTIES FOLDER ${SENTRY_FOLDER}) - set_target_properties(crashpad_handler PROPERTIES FOLDER ${SENTRY_FOLDER}) - set_target_properties(crashpad_handler_lib PROPERTIES FOLDER ${SENTRY_FOLDER}) - set_target_properties(crashpad_minidump PROPERTIES FOLDER ${SENTRY_FOLDER}) - set_target_properties(crashpad_snapshot PROPERTIES FOLDER ${SENTRY_FOLDER}) - set_target_properties(crashpad_tools PROPERTIES FOLDER ${SENTRY_FOLDER}) - set_target_properties(crashpad_util PROPERTIES FOLDER ${SENTRY_FOLDER}) - set_target_properties(crashpad_zlib PROPERTIES FOLDER ${SENTRY_FOLDER}) - set_target_properties(mini_chromium PROPERTIES FOLDER ${SENTRY_FOLDER}) - if(CRASHPAD_WER_ENABLED) - set_target_properties(crashpad_wer PROPERTIES FOLDER ${SENTRY_FOLDER}) - endif() + if(DEFINED SENTRY_FOLDER) + set_target_properties(crashpad_client PROPERTIES FOLDER ${SENTRY_FOLDER}) + set_target_properties(crashpad_compat PROPERTIES FOLDER ${SENTRY_FOLDER}) + set_target_properties(crashpad_getopt PROPERTIES FOLDER ${SENTRY_FOLDER}) + set_target_properties(crashpad_handler PROPERTIES FOLDER ${SENTRY_FOLDER}) + set_target_properties(crashpad_handler_lib PROPERTIES FOLDER ${SENTRY_FOLDER}) + set_target_properties(crashpad_minidump PROPERTIES FOLDER ${SENTRY_FOLDER}) + set_target_properties(crashpad_snapshot PROPERTIES FOLDER ${SENTRY_FOLDER}) + set_target_properties(crashpad_tools PROPERTIES FOLDER ${SENTRY_FOLDER}) + set_target_properties(crashpad_util PROPERTIES FOLDER ${SENTRY_FOLDER}) + set_target_properties(crashpad_zlib PROPERTIES FOLDER ${SENTRY_FOLDER}) + set_target_properties(mini_chromium PROPERTIES FOLDER ${SENTRY_FOLDER}) + if(CRASHPAD_WER_ENABLED) + set_target_properties(crashpad_wer PROPERTIES FOLDER ${SENTRY_FOLDER}) endif() + endif() - target_link_libraries(sentry PRIVATE - $ - $ - ) - install(EXPORT crashpad_export NAMESPACE sentry_crashpad:: FILE sentry_crashpad-targets.cmake - DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" - ) - if(WIN32 AND MSVC) - sentry_install(FILES $ + target_link_libraries(sentry PRIVATE + $ + $ + ) + install(EXPORT crashpad_export NAMESPACE sentry_crashpad:: FILE sentry_crashpad-targets.cmake + DESTINATION "${CMAKE_INSTALL_CMAKEDIR}" + ) + if(WIN32 AND MSVC) + sentry_install(FILES $ + DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL) + if (CRASHPAD_WER_ENABLED) + sentry_install(FILES $ DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL) - if (CRASHPAD_WER_ENABLED) - sentry_install(FILES $ - DESTINATION "${CMAKE_INSTALL_BINDIR}" OPTIONAL) - endif() endif() endif() add_dependencies(sentry crashpad::handler) @@ -496,7 +488,11 @@ elseif(SENTRY_BACKEND_BREAKPAD) # system breakpad is using pkg-config, see `external/breakpad/breakpad-client.pc.in` find_package(PkgConfig REQUIRED) pkg_check_modules(BREAKPAD REQUIRED IMPORTED_TARGET breakpad-client) - target_link_libraries(sentry PUBLIC PkgConfig::BREAKPAD) + if(SENTRY_BUILD_SHARED_LIBS) + target_link_libraries(sentry PRIVATE PkgConfig::BREAKPAD) + else() + target_link_libraries(sentry PUBLIC PkgConfig::BREAKPAD) + endif() else() add_subdirectory(external) target_include_directories(sentry PRIVATE diff --git a/README.md b/README.md index 6cc4b1454..3c809b50c 100644 --- a/README.md +++ b/README.md @@ -227,9 +227,9 @@ using `cmake -D BUILD_SHARED_LIBS=OFF ..`. Sentry can use different backends depending on platform. - **crashpad**: This uses the out-of-process crashpad handler. It is currently - only supported on Desktop OSs, and used as the default on Windows and macOS. + only supported on Desktop OSs, and used as the default on Windows, Linux and macOS. - **breakpad**: This uses the in-process breakpad handler. It is currently - only supported on Desktop OSs, and used as the default on Linux. + only supported on Desktop OSs. - **inproc**: A small in-process handler which is supported on all platforms, and is used as default on Android. - **none**: This builds `sentry-native` without a backend, so it does not handle @@ -238,12 +238,8 @@ using `cmake -D BUILD_SHARED_LIBS=OFF ..`. - `SENTRY_INTEGRATION_QT` (Default: OFF): Builds the Qt integration, which turns Qt log messages into breadcrumbs. -- `SENTRY_BREAKPAD_SYSTEM` / `SENTRY_CRASHPAD_SYSTEM` (Default: OFF): - This instructs the build system to use system-installed breakpad or crashpad - libraries instead of using the in-tree version. This is generally not recommended - for crashpad, as sentry uses a patched version that has attachment support. - This is being worked on upstream as well, and a future version might work with - an unmodified crashpad version as well. +- `SENTRY_BREAKPAD_SYSTEM` (Default: OFF): + This instructs the build system to use system-installed breakpad libraries instead of using the in-tree version. | Feature | Windows | macOS | Linux | Android | iOS | | ---------- | ------- | ----- | ----- | ------- | --- | diff --git a/include/sentry.h b/include/sentry.h index fe9918488..bba0dd0e7 100644 --- a/include/sentry.h +++ b/include/sentry.h @@ -30,7 +30,7 @@ extern "C" { # define SENTRY_SDK_NAME "sentry.native" # endif #endif -#define SENTRY_SDK_VERSION "0.6.7" +#define SENTRY_SDK_VERSION "0.7.0" #define SENTRY_SDK_USER_AGENT SENTRY_SDK_NAME "/" SENTRY_SDK_VERSION /* common platform detection */ @@ -90,7 +90,7 @@ extern "C" { /* context type dependencies */ #ifdef _WIN32 -# include +# include #else # include #endif diff --git a/sentry-config.cmake.in b/sentry-config.cmake.in index 89ea34511..70ce7d3c5 100644 --- a/sentry-config.cmake.in +++ b/sentry-config.cmake.in @@ -2,19 +2,32 @@ set(SENTRY_BACKEND @SENTRY_BACKEND@) set(SENTRY_TRANSPORT @SENTRY_TRANSPORT@) +set(SENTRY_BUILD_SHARED_LIBS @SENTRY_BUILD_SHARED_LIBS@) +set(SENTRY_LINK_PTHREAD @SENTRY_LINK_PTHREAD@) -if(SENTRY_BACKEND STREQUAL "crashpad") - if(@SENTRY_CRASHPAD_SYSTEM@) - find_package(crashpad REQUIRED) - else() - include("${CMAKE_CURRENT_LIST_DIR}/sentry_crashpad-targets.cmake") +if(SENTRY_BACKEND STREQUAL "crashpad" AND NOT SENTRY_BUILD_SHARED_LIBS) + include("${CMAKE_CURRENT_LIST_DIR}/sentry_crashpad-targets.cmake") + if(NOT MSVC AND NOT SENTRY_BUILD_SHARED_LIBS) + find_package(ZLIB REQUIRED) + endif() +endif() + +if(SENTRY_BACKEND STREQUAL "breakpad" AND NOT SENTRY_BUILD_SHARED_LIBS) + set(SENTRY_BREAKPAD_SYSTEM @SENTRY_BREAKPAD_SYSTEM@) + if(SENTRY_BREAKPAD_SYSTEM) + find_package(PkgConfig REQUIRED) + pkg_check_modules(BREAKPAD REQUIRED IMPORTED_TARGET breakpad-client) endif() endif() include("${CMAKE_CURRENT_LIST_DIR}/sentry-targets.cmake") -if(SENTRY_TRANSPORT STREQUAL "curl" AND NOT @BUILD_SHARED_LIBS@) +if(SENTRY_TRANSPORT STREQUAL "curl" AND (NOT @BUILD_SHARED_LIBS@ OR NOT SENTRY_BUILD_SHARED_LIBS)) find_package(CURL REQUIRED) set_property(TARGET sentry::sentry APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CURL_LIBRARIES}) endif() + +if(SENTRY_LINK_PTHREAD AND NOT SENTRY_BUILD_SHARED_LIBS) + find_package(Threads REQUIRED) +endif() diff --git a/src/sentry_core.c b/src/sentry_core.c index 43309b67f..24cf52539 100644 --- a/src/sentry_core.c +++ b/src/sentry_core.c @@ -292,29 +292,27 @@ set_user_consent(sentry_user_consent_t new_val) { SENTRY_WITH_OPTIONS (options) { if (sentry__atomic_store((long *)&options->user_consent, new_val) - == new_val) { - // nothing was changed - break; // SENTRY_WITH_OPTIONS - } - - if (options->backend && options->backend->user_consent_changed_func) { - options->backend->user_consent_changed_func(options->backend); - } + != new_val) { + if (options->backend + && options->backend->user_consent_changed_func) { + options->backend->user_consent_changed_func(options->backend); + } - sentry_path_t *consent_path - = sentry__path_join_str(options->database_path, "user-consent"); - switch (new_val) { - case SENTRY_USER_CONSENT_GIVEN: - sentry__path_write_buffer(consent_path, "1\n", 2); - break; - case SENTRY_USER_CONSENT_REVOKED: - sentry__path_write_buffer(consent_path, "0\n", 2); - break; - case SENTRY_USER_CONSENT_UNKNOWN: - sentry__path_remove(consent_path); - break; + sentry_path_t *consent_path + = sentry__path_join_str(options->database_path, "user-consent"); + switch (new_val) { + case SENTRY_USER_CONSENT_GIVEN: + sentry__path_write_buffer(consent_path, "1\n", 2); + break; + case SENTRY_USER_CONSENT_REVOKED: + sentry__path_write_buffer(consent_path, "0\n", 2); + break; + case SENTRY_USER_CONSENT_UNKNOWN: + sentry__path_remove(consent_path); + break; + } + sentry__path_free(consent_path); } - sentry__path_free(consent_path); } } diff --git a/tests/assertions.py b/tests/assertions.py index 08f2936ab..f12ec9972 100644 --- a/tests/assertions.py +++ b/tests/assertions.py @@ -58,9 +58,9 @@ def assert_meta( } expected_sdk = { "name": "sentry.native", - "version": "0.6.7", + "version": "0.7.0", "packages": [ - {"name": "github:getsentry/sentry-native", "version": "0.6.7"}, + {"name": "github:getsentry/sentry-native", "version": "0.7.0"}, ], } if is_android: diff --git a/tests/test_integration_http.py b/tests/test_integration_http.py index fe3740a6c..ee915f00e 100644 --- a/tests/test_integration_http.py +++ b/tests/test_integration_http.py @@ -24,7 +24,7 @@ pytestmark = pytest.mark.skipif(not has_http, reason="tests need http") auth_header = ( - "Sentry sentry_key=uiaeosnrtdy, sentry_version=7, sentry_client=sentry.native/0.6.7" + "Sentry sentry_key=uiaeosnrtdy, sentry_version=7, sentry_client=sentry.native/0.7.0" ) diff --git a/tests/unit/test_consent.c b/tests/unit/test_consent.c index f26af345b..d81476c27 100644 --- a/tests/unit/test_consent.c +++ b/tests/unit/test_consent.c @@ -28,6 +28,10 @@ SENTRY_TEST(basic_consent_tracking) init_consenting_sentry(); sentry_user_consent_give(); + // testing correct options ref/decref during double + // `sentry_user_consent_give` call see + // https://github.com/getsentry/sentry-native/pull/922 + sentry_user_consent_give(); TEST_CHECK_INT_EQUAL(sentry_user_consent_get(), SENTRY_USER_CONSENT_GIVEN); sentry_close(); init_consenting_sentry();