Skip to content

feat(crashpad): add option to delay shutdown until crash report upload completes (Linux) #1153

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

Merged
merged 16 commits into from
Mar 25, 2025

Conversation

JoshuaMoelans
Copy link
Member

@JoshuaMoelans JoshuaMoelans commented Feb 20, 2025

In some scenarios, waiting for the upload to complete makes more sense than trying to quickly kill the crashed process.
Crashpad PR getsentry/crashpad#121

We start by providing this for Linux, since this is the most common use-case for this kind of wait-before-shutdown behavior. If the need arises, we can reconsider adding it for other platforms as well.

Manual testing

Testing in CI is tricky, so we opted to test this on a local Docker setup instead. Below are the example Dockerfile and docker-compose.yml that we used to test this feature

dockerfile
FROM ubuntu:22.04

# Install required dependencies
RUN apt-get update && apt-get install -y \
    build-essential \
    cmake \
    git \
    python3 \
    python3-pip \
    pkg-config \
    systemd \
    libcurl4-openssl-dev

# Set working directory
WORKDIR /sentry-native

# Copy sentry-native source code
COPY . .

# Clean any existing build
RUN rm -rf build/

# Build the project
RUN cmake -B build \
    -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/sentry-native/build \
    -DSENTRY_BACKEND=crashpad

RUN cmake --build build --target sentry_example
docker-compose.yml
services:
  sentry-example:
    environment:
      - SENTRY_DSN=<your_sentry_DSN>
    build: .
    volumes:
      - .:/sentry-native:rw
      - /sentry-native/build  # This prevents the build directory from being mounted from host
    cap_add:
      - SYS_PTRACE
    security_opt:
      - seccomp:unconfined
    command: ./build/sentry_example log crash sleep capture-multiple
# alternatively command: ./build/sentry_example log crash sleep capture-multiple crashpad-wait-for-upload

Copy link

github-actions bot commented Feb 20, 2025

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 3f932ff

Copy link

codecov bot commented Feb 20, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 82.63%. Comparing base (4ebdbe9) to head (7dfb073).
Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1153      +/-   ##
==========================================
- Coverage   82.67%   82.63%   -0.04%     
==========================================
  Files          53       53              
  Lines        7954     7959       +5     
  Branches     1246     1246              
==========================================
+ Hits         6576     6577       +1     
- Misses       1264     1268       +4     
  Partials      114      114              

# Conflicts:
#	CHANGELOG.md
#	src/backends/sentry_backend_crashpad.cpp
#	src/sentry_options.c
#	src/sentry_options.h
#	tests/test_integration_crashpad.py
@JoshuaMoelans JoshuaMoelans marked this pull request as ready for review March 24, 2025 16:31
@JoshuaMoelans
Copy link
Member Author

Do we already want to add the dockerfile & docker-compose files to the repo for posterity, or should we just leave them in the PR description as-is (until we add a proper Docker test into our CI testing setup)

@supervacuus
Copy link
Collaborator

Do we already want to add the dockerfile & docker-compose files to the repo for posterity, or should we just leave them in the PR description as-is (until we add a proper Docker test into our CI testing setup)

I think it is enough to have it here.

@JoshuaMoelans JoshuaMoelans changed the title feat(crashpad): add option to delay shutdown until upload thread completes feat(crashpad): add option to delay shutdown until crash report upload completes (Linux) Mar 25, 2025
@JoshuaMoelans JoshuaMoelans merged commit ce9d742 into master Mar 25, 2025
30 checks passed
@JoshuaMoelans JoshuaMoelans deleted the joshua/feat/crashpad_await_shutdown branch March 25, 2025 13:57
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

Successfully merging this pull request may close these issues.

2 participants