Skip to content

Commit

Permalink
Upstream sentry-native (does not update crashpad and breakpad refs) (#15
Browse files Browse the repository at this point in the history
)

* feat: Add support for Qt 6 (getsentry#509)

* fix: Windows SDK Compiler Warning (getsentry#511)

* fix: Validate tm put into strftime (getsentry#510)

* fix: Rewrite the Linux module finder (getsentry#431)

It now works in memory, without requiring to mmap the libraries again,
which should make it work correctly on android when loading libraries
directly from apk or appbundle files.

The new code will keep track of readable memory maps and will
translate read requests based on the offset of those memory maps,
making sure that we actually can read whatever we are trying to read.

* build: Avoid building all targets (getsentry#512)

It looks like cmake is broken and builds ALL the targets when the parallel option is specified first, lol

* fix: Update Crashpad to 2021-04-12 and fix macOS universal build (getsentry#513)

* feat: Invoke before_send hook when using Crashpad (getsentry#519)

* feat: Add more Event Payload convenience methods (getsentry#517)

Adds:
* `sentry_value_new_exception`
* `sentry_value_new_thread`
* `sentry_value_new_stacktrace`
* `sentry_event_add_exception`
* `sentry_event_add_thread`

Deprecates `sentry_event_value_add_stacktrace`

* feat: Introduce `sentry_close` (getsentry#518)

This replaces the former `sentry_shutdown`, which is being forwarded.

* meta: Prepare Changelog for upcoming release (getsentry#522)

* ref: Pass options to scope apply directly (getsentry#521)

* fix: Further clean up platform libraries for static linking (getsentry#523)

* fix: Better macOS availability checks (getsentry#524)

This should allow building on older macOS versions as well as
running on older versions by fixing the usage of __builtin_available,
and adding a different clock source for older macOS versions.

* release: 0.4.9

* fix: Avoid double-free on invalid DSN (getsentry#527)

* meta: Use correct libunwindstack commit

* fix: Allow for Unity builds (getsentry#536)

* ref: Add more testcases that trigger crashes in various ways (getsentry#538)

* ref(craft): Modernize Craft config (getsentry#543)

* fix: Update venv and test-discovery Makefile targets (getsentry#544)

* fix: Avoid recursion when using `sentry_reinstall_backend` (getsentry#548)

Previously, the `inproc` and `crashpad` (on linux) backends didn’t correctly reset their signal handlers when doing `reinstall_backend` (or multiple `init` calls for that matter).
This has led to an infinite loop generating crashes.

The fix now correctly unregisters the inproc/crashpad signal handlers, and adds an integration test using `reinstall_backend` to make sure we do not end up in an infinite loop.

Co-authored-by: Mischa Alff <mischa@mutate.se>

* fix: Address -Wundef warning for SENTRY_UNITTEST defines (getsentry#549)

* build: Set 32-bit option for compiling assembly as well (getsentry#550)

This fixes compilation of breakpad for 32-bit systems

* meta: Update break/crashpad to 2021-06-14 (getsentry#552)

* fix: Shorten/Split Locked sections to avoid deadlock (getsentry#551)

We have received a report that the `sentry_get_modules_list` on mac can deadlock
when other code concurrently does a `dlopen` and thus invokes the `add_image`
callback from a different thread.

We shorten/split the locked blocks in order to avoid holding a lock in the
`get_modules` function whenever the `add_image` function is being invoked possibly
from other threads.

* fix: Tighten Stack Usage (getsentry#553)

According to some docs, JVM/JNI stacks on Android can be as small as
32K, and our own sigaltstack is not much larger with 64K.
Make sure to avoid large stack allocations as much as possible.

We have especially seen the literal content of `/proc/self/maps` as well
as formatted addresses inside corrupted release/environment attributes,
which might point to overflows that write into a previously allocated
release/environment string.

* meta: Update Changelog (getsentry#556)

* release: 0.4.10

* reformat

* fix: Make Linux modulefinder/unwinder safer (getsentry#559)

This is using the `process_vm_read` call to safely poke at random memory. It also makes sure to shim the libc provided call with a direct syscall for older Android devices.

* docs: Try to better explain unwind API (getsentry#564)

* fix: Make Crashpad Backend respect max_breadcrumbs setting (getsentry#566)

* fix: Cancel slow winhttp requests on shutdown (getsentry#570)

Co-authored-by: Gerhard Herbert <gerhard.herbert@avira.com>

* fix: Properly close the background worker thread on timeout (getsentry#571)

* fix: Possible race conditions in init/close and sessions (getsentry#545)

* meta: Draft Changelog (getsentry#572)

* release: 0.4.11

* feat: Make shutdown timeout customizable (getsentry#577)

Co-authored-by: Andrei Muraru <andrei.muraru@avira.com>

* CMake: Link to the CURL::libcurl target when available (getsentry#579)

Caters better for newer cmake versions.

* meta: Update crashpad to 2021-07-14 (getsentry#580)

* fix: Properly use `SENTRY_BUILD_RUNTIMESTATIC` for `sentry_fuzz_json` unit test (getsentry#583)

* meta: Update break/crashpad to 2021-07-28 (getsentry#584)

* release: 0.4.12

* fix: Increment CXX standard to 14 to allow crashpad build (getsentry#585)

Fixes getsentry#574

* meta: Bump python dependencies (getsentry#600)

The old version of pytest breaks with python 3.10 which changed a
little how code object internals work.  Since python 3.10 is now
released it starts being used in CI.

* fix: Ensure that a valid DSN has a public_key (getsentry#598)

* feat: AIX support (getsentry#593)

* CMake: Check whether libcurl was already found (getsentry#602)

Currently when there is any other project that brings libcurl as a dependency,
the build fails with “Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR)“,
even though libcurl has already added as CURL::libcurl library.

This patch adds a check for CURL_FOUND, to indicate that the library was already
found, if set by another project. It also skips the additional find_package()
step so it does not fail.

Signed-off-by: Ladislav Macoun <ladislavmacoun@gmail.com>

* CMake: fix `SENTRY_BACKEND` defined in outer scope (getsentry#603)

* CMake: add ability to set solution folder name (getsentry#604)

* [pull] master from getsentry:master (#14)

* ci(codechecker): Workaround for code checker not building due to node issues (getsentry#615)

* meta: Update breakpad/crashpad to 2021-12-03 (getsentry#614)

* feat(tracing): Add config options (getsentry#613)

* fix: Correct changelog entry (getsentry#622)

* meta: Bump breakpad (getsentry#621)

* feat: Add internal UUID types (getsentry#616)

This adds in support for internal UUIDs needed by tracing,
such as the trace ID and the span ID.
 
The major difference between this and the "standard" UUID 
is that the hyphens are stripped during serialization. sentry 
appears to not consider the hyphenated representations of 
these UUIDs to be valid for certain fields in an event.

* meta: Update changelog (getsentry#625)

* release: 0.4.13

* feat(tracing): Groundwork to add tracing context to all events (getsentry#617)

This adds the appropriate stubs and fields to 
start storing spans on the (universal) scope. 
No actual logic has been added to actually 
support setting spans on the scope itself.

The focus of this is to begin including tracing 
info in the context on all events if there is a 
transaction set on the scope. It does this fairly 
naively right now as the tooling to merge 
`sentry_value_t`s are basically nonexistent.

* ci: Make integration tests capable of reading the non-backwards compatible version number for Big Sur (getsentry#627)

* feat(tracing): Basic transaction context creation (getsentry#619)

This adds in the ability to create and manipulate transaction contexts as defined in 
https://develop.sentry.dev/sdk/performance/#new-span-and-transaction-classes, 
under Transaction Interface.

Instead of defining several transaction constructor functions with varying names 
(since overloading doesn't exist), the decision has been made to have the user 
construct an "inactive" transaction which should be fed into the SDK's 
implementation of `start_transaction`. This follows an existing pattern in the SDK 
where exceptions, threads, messages, etc can be constructed but they must be 
explicitly added to an event to be sent to sentry.

* feat(tracing): Support basic sampling of transactions (getsentry#620)

If an event is a transaction, event flushing should determine 
discard or forward the transaction to sentry based on the
sample rate as configured in sentry options. Follows the 
sampling rules as defined in 
https://develop.sentry.dev/sdk/performance/#sampling-context.

This does not take into consideration parent sampling as 
that property is currently unimplemented on the transaction 
context.

* feat(tracing): Introduce a helper that identifies events that are transactions (getsentry#628)

* feat(tracing): Restrict `sentry_capture_event` so it only sends non-transaction events (getsentry#629)

Prevent the public API from being used to send transaction events
as another transaction-specific function is meant to be used to 
accomplish this.

* fix: Avoid deadlocks with uninitialized options (getsentry#639)

The `SENTRY_WITH_OPTIONS_MUT` was a footgun since it never unlocked when
the options were NULL (uninitialized).
This removes the macro and replaces its uses with explicit lock/unlock calls.

* feat(tracing): Add in basic Envelope support for Transactions (getsentry#630)

* feat(tracing): Allow manual creation and sending of spanless Transactions (getsentry#631)

* feat(tracing): Defer some transaction validation and allow creation of internal spans (getsentry#633)

Co-authored-by: relaxolotl <5597345+relaxolotl@users.noreply.github.com>
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
Co-authored-by: getsentry-bot <bot@sentry.io>
Co-authored-by: Arpad Borsos <swatinem@swatinem.de>
Co-authored-by: Arpad Borsos <arpad.borsos@sentry.io>

Co-authored-by: Tor Arne Vestbø <torarnv@gmail.com>
Co-authored-by: Arpad Borsos <arpad.borsos@sentry.io>
Co-authored-by: Luke Street <luke@street.dev>
Co-authored-by: getsentry-bot <bot@getsentry.com>
Co-authored-by: Sentry Bot <getsentry-bot@users.noreply.github.com>
Co-authored-by: Arpad Borsos <swatinem@swatinem.de>
Co-authored-by: bschatt <44769431+bschatt@users.noreply.github.com>
Co-authored-by: Burak Yigit Kaya <byk@sentry.io>
Co-authored-by: MikeRumplerSentry <85497711+MikeRumplerSentry@users.noreply.github.com>
Co-authored-by: Mischa Alff <mischa@mutate.se>
Co-authored-by: Michał Janiszewski <janisozaur@users.noreply.github.com>
Co-authored-by: getsentry-bot <bot@sentry.io>
Co-authored-by: Gerhard Herbert <gerhard.herbert@avira.com>
Co-authored-by: andrei-mu <andrei5008@gmail.com>
Co-authored-by: Andrei Muraru <andrei.muraru@avira.com>
Co-authored-by: pastdue <30942300+past-due@users.noreply.github.com>
Co-authored-by: Roshan Padaki <roshanpadaki@gmail.com>
Co-authored-by: mjvankampen <markjanvankampen@gmail.com>
Co-authored-by: Floris Bruynooghe <flub@sentry.io>
Co-authored-by: Calvin Buckley <calvin@cmpct.info>
Co-authored-by: Ladislav <ladislavmacoun@gmail.com>
Co-authored-by: Mikhail Paulyshka <me@mixaill.tk>
Co-authored-by: pull[bot] <39814207+pull[bot]@users.noreply.github.com>
Co-authored-by: relaxolotl <5597345+relaxolotl@users.noreply.github.com>
Co-authored-by: Sebastian Zivota <loewenheim@users.noreply.github.com>
  • Loading branch information
1 parent 4452840 commit ce34056
Show file tree
Hide file tree
Showing 46 changed files with 1,697 additions and 67 deletions.
26 changes: 26 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
# Changelog

## 0.4.13

**Features**

- Add client-side stackwalking on Linux, Windows, and macOS (disabled by default).
- CMake: add ability to set solution folder name.
- Add AIX support.

**Fixes**

- CMake: check whether libcurl was already found.
- Increment CXX standard version to 14 to allow crashpad to build.

**Internal**:

- Update Crashpad and Breakpad submodules to 2021-12-03.

**Thank you**:

Features, fixes and improvements in this release have been contributed by:

- [@Mixaill](https://github.com/Mixaill)
- [@ladislavmacoun](https://github.com/ladislavmacoun)
- [@NattyNarwhal](https://github.com/NattyNarwhal)
- [@mjvankampen](https://github.com/mjvankampen)

## 0.4.12

**Features**:
Expand Down
51 changes: 47 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/sentry")

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(LINUX TRUE)
elseif(CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400")
set(AIX TRUE)
endif()

#setup sentry library type
Expand Down Expand Up @@ -93,7 +95,7 @@ endif()

if(WIN32)
set(SENTRY_DEFAULT_TRANSPORT "winhttp")
elseif((APPLE AND NOT IOS) OR LINUX)
elseif((APPLE AND NOT IOS) OR LINUX OR AIX)
set(SENTRY_DEFAULT_TRANSPORT "curl")
else()
set(SENTRY_DEFAULT_TRANSPORT "none")
Expand Down Expand Up @@ -137,8 +139,10 @@ else()
set(SENTRY_DEFAULT_BACKEND "inproc")
endif()

set(SENTRY_BACKEND ${SENTRY_DEFAULT_BACKEND} CACHE STRING
"The sentry backend responsible for reporting crashes, can be either 'none', 'inproc', 'breakpad' or 'crashpad'.")
if(NOT DEFINED SENTRY_BACKEND)
set(SENTRY_BACKEND ${SENTRY_DEFAULT_BACKEND} CACHE STRING
"The sentry backend responsible for reporting crashes, can be either 'none', 'inproc', 'breakpad' or 'crashpad'.")
endif()

if(SENTRY_BACKEND STREQUAL "crashpad")
set(SENTRY_BACKEND_CRASHPAD TRUE)
Expand Down Expand Up @@ -236,6 +240,10 @@ endif()

set_target_properties(sentry PROPERTIES PUBLIC_HEADER "include/sentry.h")

if(DEFINED SENTRY_FOLDER)
set_target_properties(sentry PROPERTIES FOLDER ${SENTRY_FOLDER})
endif()

# check size type
include(CheckTypeSize)
check_type_size("long" CMAKE_SIZEOF_LONG)
Expand All @@ -257,8 +265,20 @@ else()
endif()
target_compile_definitions(sentry PRIVATE SIZEOF_LONG=${CMAKE_SIZEOF_LONG})

# AIX needs libm for isnan used in test suite
if(CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400")
target_link_libraries(sentry PRIVATE m)
endif()
# On IBM i PASE, flock is in libutil. Here because "sentry" exists now.
if(CMAKE_SYSTEM_NAME STREQUAL "OS400")
target_link_libraries(sentry PRIVATE util)
endif()

if(SENTRY_TRANSPORT_CURL)
find_package(CURL REQUIRED)
if(NOT CURL_FOUND) # Some other lib might bring libcurl already
find_package(CURL REQUIRED)
endif()

if(TARGET CURL::libcurl) # Only available in cmake 3.12+
target_link_libraries(sentry PRIVATE CURL::libcurl)
else()
Expand Down Expand Up @@ -434,6 +454,20 @@ if(SENTRY_BACKEND_CRASHPAD)
set_property(TARGET mini_chromium PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>: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})
endif()

target_link_libraries(sentry PRIVATE
$<BUILD_INTERFACE:crashpad::client>
$<INSTALL_INTERFACE:sentry_crashpad::client>
Expand Down Expand Up @@ -462,6 +496,11 @@ elseif(SENTRY_BACKEND_BREAKPAD)
target_link_libraries(sentry PRIVATE
breakpad_client
)

if(DEFINED SENTRY_FOLDER)
set_target_properties(breakpad_client PROPERTIES FOLDER ${SENTRY_FOLDER})
endif()

if(NOT SENTRY_BUILD_SHARED_LIBS)
sentry_install(TARGETS breakpad_client EXPORT sentry
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
Expand Down Expand Up @@ -538,5 +577,9 @@ if(SENTRY_BUILD_EXAMPLES)
set_property(TARGET sentry_example PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()

if(DEFINED SENTRY_FOLDER)
set_target_properties(sentry_example PROPERTIES FOLDER ${SENTRY_FOLDER})
endif()

add_test(NAME sentry_example COMMAND sentry_example)
endif()
13 changes: 10 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ be done manually.

Creates a python virtualenv, and runs all the tests through `pytest`.

**Running integration-tests manually**:
**Running integration tests manually**:

$ pytest --verbose --maxfail=1 --capture=no tests/

Expand All @@ -47,13 +47,20 @@ can also be invoked directly.
The `maxfail` parameter will abort after the first failure, and `capture=no`
will print the complete compiler output, and test log.

**Running unit-tests manually**:
**Running unit tests**:

$ make test-unit

Unit tests also have a dedicated `make` target, if they need to be run separately
from the integration tests.

**Running unit tests manually**:

$ cmake -B build -D CMAKE_RUNTIME_OUTPUT_DIRECTORY=$(pwd)/build
$ cmake --build build --target sentry_test_unit
$ ./build/sentry_test_unit

The unit-tests are a separate executable target and can be built and run on
The unit tests are a separate executable target and can be built and run on
their own.

## How to interpret CI failures
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ build/sentry_test_unit: build
test: update-test-discovery test-integration
.PHONY: test

test-unit: update-test-discovery build/sentry_test_unit
./build/sentry_test_unit
.PHONY: test-unit

test-integration: setup-venv
.venv/bin/pytest tests --verbose
.PHONY: test-integration
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ The SDK supports different features on the target platform:
have the `curl` library available. On other platforms, library users need to
implement their own transport, based on the `function transport` API.
- **Crashpad Backend** is currently only supported on Linux, Windows and macOS.
- **Client-side stackwalking** is currently only supported on Linux, Windows, and macOS.

## Building and Installation

Expand Down Expand Up @@ -277,6 +278,15 @@ Legend:
- ✓ supported
- unsupported

- `SENTRY_FOLDER` (Default: not defined):
Sets the sentry-native projects folder name for generators which support project hierarchy (like Microsoft Visual Studio).
To use this feature you need to enable hierarchy via [`USE_FOLDERS` property](https://cmake.org/cmake/help/latest/prop_gbl/USE_FOLDERS.html)

- `CRASHPAD_ENABLE_STACKTRACE` (Default: OFF):
This enables client-side stackwalking when using the crashpad backend. Stack unwinding will happen on the client's machine
and the result will be submitted to Sentry attached to the generated minidump.
Note that this feature is still experimental.

### Build Targets

- `sentry`: This is the main library and the only default build target.
Expand Down
24 changes: 24 additions & 0 deletions examples/example.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ has_arg(int argc, char **argv, const char *arg)
return false;
}

#ifdef SENTRY_PLATFORM_AIX
// AIX has a null page mapped to the bottom of memory, which means null derefs
// don't segfault. try dereferencing the top of memory instead; the top nibble
// seems to be unusable.
static void *invalid_mem = (void *)0xFFFFFFFFFFFFFF9B; // -100 for memset
#else
static void *invalid_mem = (void *)1;
#endif

static void
trigger_crash()
Expand Down Expand Up @@ -86,6 +93,10 @@ main(int argc, char **argv)
options, sentry_transport_new(print_envelope));
}

if (has_arg(argc, argv, "capture-transaction")) {
sentry_options_set_traces_sample_rate(options, 1.0);
}

sentry_init(options);

if (!has_arg(argc, argv, "no-setup")) {
Expand Down Expand Up @@ -201,6 +212,19 @@ main(int argc, char **argv)
sentry_capture_event(event);
}

if (has_arg(argc, argv, "capture-transaction")) {
sentry_value_t tx_ctx
= sentry_value_new_transaction_context("I'm a little teapot",
"Short and stout here is my handle and here is my spout");

if (has_arg(argc, argv, "unsample-tx")) {
sentry_transaction_context_set_sampled(tx_ctx, 0);
}

sentry_value_t tx = sentry_transaction_start(tx_ctx);
sentry_transaction_finish(tx);
}

// make sure everything flushes
sentry_close();

Expand Down
Loading

0 comments on commit ce34056

Please sign in to comment.