Skip to content

Sentry-native + Breakpad is failing to show SIGSEGV crash info. #1203

Closed

Description

@zongyangbigpolo

Description
I'm testing Sentry-native and Breakpad on my macOS machine. I've found that if I introduce a pointer access violation or send a SIGABRT signal, crash reports are successfully sent to the Sentry website. However, when I send a SIGSEGV signal to my program, although the crash information is visible in the local macOS console, no crash information is sent to the remote Sentry website. I've tried this multiple times without success. I also tried SIGFPE, SIGILL, and SIGBUS signals, and none of them resulted in crash reports being sent to Sentry. Previously, when I was using crashpad_handler, SIGSEGV signals were correctly sending crash information to Sentry. (My program has 10 processes, which results in 10 additional crashpad_handler processes, significantly increasing CPU and memory consumption, so I'm switching to the Breakpad solution.)

The only thing I've noticed is that when the SIGSEGV signal occurs, the content length of the crash information being sent is very short, only around 300 bytes. Normal crash information is usually over 100,000 bytes. Can you please help me analyze this? Thank you very much.

Environment
MacOS 15.2
sentry-native 0.7.20

  • OS: [e.g. Windows 10, 64-bit] MacOS 15.2
  • Compiler: [e.g. MSVC 19] clang

Log output

* Host o167200.ingest.us.sentry.io:443 was resolved.
* IPv6: (none)
* IPv4: 34.120.195.249
*   Trying 34.120.195.249:443...
* Connected to o167200.ingest.us.sentry.io (34.120.195.249) port 443
* ALPN: curl offers h2,http/1.1
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256 / [blank] / UNDEF
* ALPN: server accepted h2
* Server certificate:
*  subject: C=US; ST=California; L=San Francisco; O=Sentry; CN=ingest.sentry.io
*  start date: Oct  3 00:00:00 2024 GMT
*  expire date: Jul 29 23:59:59 2025 GMT
*  subjectAltName: host "o167200.ingest.us.sentry.io" matched cert's "*.ingest.us.sentry.io"
*  issuer: C=US; O=DigiCert Inc; CN=DigiCert Global G2 TLS RSA SHA256 2020 CA1
*  SSL certificate verify ok.
* using HTTP/2
* [HTTP/2] [1] OPENED stream for https://o167200.ingest.us.sentry.io:443/api/4508799326420993/envelope/
* [HTTP/2] [1] [:method: POST]
* [HTTP/2] [1] [:scheme: https]
* [HTTP/2] [1] [:authority: o167200.ingest.us.sentry.io]
* [HTTP/2] [1] [:path: /api/4508799326420993/envelope/]
* [HTTP/2] [1] [user-agent: sentry.native/0.7.20]
* [HTTP/2] [1] [accept: */*]
* [HTTP/2] [1] [x-sentry-auth: Sentry sentry_key=**can't be shown**, sentry_version=7, sentry_client=sentry.native/0.7.20]
* [HTTP/2] [1] [content-type: application/x-sentry-envelope]
* [HTTP/2] [1] [content-length: 337]
> POST /api/4508799326420993/envelope/ HTTP/2
Host: o167200.ingest.us.sentry.io
User-Agent: sentry.native/0.7.20
Accept: */*
x-sentry-auth:Sentry sentry_key=**can't be shown**, sentry_version=7, sentry_client=sentry.native/0.7.20
content-type:application/x-sentry-envelope
content-length:337

* upload completely sent off: 337 bytes
< HTTP/2 200 
< server: nginx
< date: Thu, 17 Apr 2025 07:26:30 GMT
< content-type: application/json
< content-length: 2
< vary: origin, access-control-request-method, access-control-request-headers
< access-control-allow-origin: *
< access-control-expose-headers: x-sentry-error,x-sentry-rate-limits,retry-after
< cross-origin-resource-policy: cross-origin
< strict-transport-security: max-age=31536000; includeSubDomains; preload
< via: 1.1 google
< alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
< 
{}* Connection #0 to host o167200.ingest.us.sentry.io left intact

The below is my init func:

int
CrashHandlerInit(void)
{
    if (g_sentry_inited) {
        // Already inited
        logMessage("Sentry already initialized.");
        return -1;
    }

    if (getExecutableName() == false) {
        logMessage("Failed to get executable name");
        return -2;
    }

    ensureLogFilePermissions();

    strncpy(g_branchName, GIT_BRANCH_NAME, sizeof(g_branchName) - 1);
    strncpy(g_versionNum, BUILD_VERSION, sizeof(g_versionNum) - 1);

    sentry_options_t *options = sentry_options_new();

    // if support multi dsn platform, use a switch case here
    // sentry_options_set_dsn(options, ctxDecodeString(DSN1));
    sentry_options_set_dsn(options,
        "https://*******");

    // sentry_options_set_handler_path(options, CRASHPADPATH); 
    // (Because I'm not using Crashpad, I commented out that line.)
    sentry_options_set_database_path(options, DATABASEPATH);

#ifdef ENVIRONMENT
    sentry_options_set_environment(options, ENVIRONMENT);
#else
    sentry_options_set_environment(options, "unknown");
#endif

    sentry_options_set_release(options, g_branchName);
    sentry_options_set_debug(options, 1);

    sentry_options_set_logger(options, sentryLogger, NULL);
    int ret = sentry_init(options);
    if (ret != 0) {
        logMessage("Failed to init Sentry with error code: %d with process "
                   "name:%s version:%s branch:%s",
            ret, g_processName, g_versionNum, g_branchName);
        return ret;
    }
    g_sentry_inited = true;

    sentry_set_tag("processName", g_processName);
    sentry_set_tag("branch", g_branchName);
    sentry_set_tag("version", g_versionNum);
    logMessage("Successfully initialized Sentry with process name: %s version: "
               "%s branch: %s",
        g_processName, g_versionNum, g_branchName);

    return 0;
}

The below is how i compile the sentry-native with breakpad:

cd build
cmake .. -DSENTRY_BACKEND=breakpad -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64"
cmake --build . --parallel

# Package the all items
INSTALL_DIR=./pkg
cmake --install . --prefix "$INSTALL_DIR"

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Apr 17, 2025
  2. added
    Bug
    and removed on Apr 17, 2025
  3. zongyangbigpolo commented on Apr 18, 2025

    @zongyangbigpolo
    Author

    I tested version 0.8.4, and the Sentry website still can't display crash information for the SIGSEGV signal.

  4. zongyangbigpolo commented on Apr 18, 2025

    @zongyangbigpolo
    Author

    0.8.4 log:

    Entering infinite loop. Send SIGSEGV or other signal to test crash handling.
    zsh: segmentation fault  sudo ./crashtest
    pli@APACMACXW7WVFW74C pkg % 
    [1]  + segmentation fault  ./crashtest
    
    pli@APACMACXW7WVFW74C pkg % sudo ./crashtest
    [sentry] INFO using database path "/private/tmp/sentry-db"
    [sentry] DEBUG starting transport
    [sentry] DEBUG starting background worker thread
    [sentry] DEBUG starting backend
    [sentry] DEBUG background worker thread started
    [sentry] DEBUG processing and pruning old runs
    [sentry] DEBUG sending envelope
    [sentry] DEBUG submitting task to background worker thread
    [sentry] DEBUG executing task on worker thread
    Sentry initialized with Breakpad backend
    Press:
    1: Capture a message
    2: Capture an error
    3: Trigger a crash
    0: Exit
    * Host o167200.ingest.us.sentry.io:443 was resolved.
    * IPv6: (none)
    * IPv4: 34.120.195.249
    *   Trying 34.120.195.249:443...
    * Connected to o167200.ingest.us.sentry.io (34.120.195.249) port 443
    * ALPN: curl offers h2,http/1.1
    *  CAfile: /etc/ssl/cert.pem
    *  CApath: none
    * SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256 / [blank] / UNDEF
    * ALPN: server accepted h2
    * Server certificate:
    *  subject: C=US; ST=California; L=San Francisco; O=Sentry; CN=ingest.sentry.io
    *  start date: Oct  3 00:00:00 2024 GMT
    *  expire date: Jul 29 23:59:59 2025 GMT
    *  subjectAltName: host "o167200.ingest.us.sentry.io" matched cert's "*.ingest.us.sentry.io"
    *  issuer: C=US; O=DigiCert Inc; CN=DigiCert Global G2 TLS RSA SHA256 2020 CA1
    *  SSL certificate verify ok.
    * using HTTP/2
    * [HTTP/2] [1] OPENED stream for https://o167200.ingest.us.sentry.io:443/api/66666/envelope/
    * [HTTP/2] [1] [:method: POST]
    * [HTTP/2] [1] [:scheme: https]
    * [HTTP/2] [1] [:authority: o167200.ingest.us.sentry.io]
    * [HTTP/2] [1] [:path: /api/4508799326420993/envelope/]
    * [HTTP/2] [1] [user-agent: sentry.native/0.8.4]
    * [HTTP/2] [1] [accept: */*]
    * [HTTP/2] [1] [x-sentry-auth: Sentry sentry_key=66666, sentry_version=7, sentry_client=sentry.native/0.8.4]
    * [HTTP/2] [1] [content-type: application/x-sentry-envelope]
    * [HTTP/2] [1] [content-length: 345]
    > POST /api/4508799326420993/envelope/ HTTP/2
    Host: o167200.ingest.us.sentry.io
    User-Agent: sentry.native/0.8.4
    Accept: */*
    x-sentry-auth:Sentry sentry_key=6666, sentry_version=7, sentry_client=sentry.native/0.8.4
    content-type:application/x-sentry-envelope
    content-length:345
    
    * upload completely sent off: 345 bytes
    < HTTP/2 200 
    < server: nginx
    < date: Fri, 18 Apr 2025 08:52:40 GMT
    < content-type: application/json
    < content-length: 2
    < vary: origin, access-control-request-method, access-control-request-headers
    < access-control-allow-origin: *
    < access-control-expose-headers: x-sentry-error,x-sentry-rate-limits,retry-after
    < cross-origin-resource-policy: cross-origin
    < strict-transport-security: max-age=31536000; includeSubDomains; preload
    < via: 1.1 google
    < alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
    < 
    {}* Connection #0 to host o167200.ingest.us.sentry.io left intact
    
  5. zongyangbigpolo commented on Apr 18, 2025

    @zongyangbigpolo
    Author

    The below is the normal log:

    Image
    pli@APACMACXW7WVFW74C pkg % ./crashtest
    [sentry] INFO using database path "/private/tmp/sentry-db"
    [sentry] DEBUG starting transport
    [sentry] DEBUG starting background worker thread
    [sentry] DEBUG starting backend
    [sentry] DEBUG background worker thread started
    [sentry] DEBUG processing and pruning old runs
    Sentry initialized with Breakpad backend
    Press:
    1: Capture a message
    2: Capture an error
    3: Trigger a crash
    4: wait sigsegv
    0: Exit
    3
    Triggering crash...
    [sentry] INFO entering breakpad minidump callback
    [sentry] DEBUG invoking `on_crash` hook
    Crash detected! Recording additional information...
    [sentry] DEBUG merging scope into event
    [sentry] DEBUG adding attachments to envelope
    [sentry] DEBUG sending envelope
    [sentry] INFO crash has been captured
    pli@APACMACXW7WVFW74C pkg % 
    pli@APACMACXW7WVFW74C pkg % 
    pli@APACMACXW7WVFW74C pkg % ./crashtest
    [sentry] INFO using database path "/private/tmp/sentry-db"
    [sentry] DEBUG starting transport
    [sentry] DEBUG starting background worker thread
    [sentry] DEBUG starting backend
    [sentry] DEBUG background worker thread started
    [sentry] DEBUG processing and pruning old runs
    [sentry] DEBUG sending envelope
    [sentry] DEBUG submitting task to background worker thread
    [sentry] DEBUG executing task on worker thread
    Sentry initialized with Breakpad backend
    Press:
    1: Capture a message
    2: Capture an error
    3: Trigger a crash
    4: wait sigsegv
    0: Exit
    * Host o167200.ingest.us.sentry.io:443 was resolved.
    * IPv6: (none)
    * IPv4: 34.120.195.249
    *   Trying 34.120.195.249:443...
    * Connected to o167200.ingest.us.sentry.io (34.120.195.249) port 443
    * ALPN: curl offers h2,http/1.1
    *  CAfile: /etc/ssl/cert.pem
    *  CApath: none
    * SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256 / [blank] / UNDEF
    * ALPN: server accepted h2
    * Server certificate:
    *  subject: C=US; ST=California; L=San Francisco; O=Sentry; CN=ingest.sentry.io
    *  start date: Oct  3 00:00:00 2024 GMT
    *  expire date: Jul 29 23:59:59 2025 GMT
    *  subjectAltName: host "o167200.ingest.us.sentry.io" matched cert's "*.ingest.us.sentry.io"
    *  issuer: C=US; O=DigiCert Inc; CN=DigiCert Global G2 TLS RSA SHA256 2020 CA1
    *  SSL certificate verify ok.
    * using HTTP/2
    * [HTTP/2] [1] OPENED stream for https://o167200.ingest.us.sentry.io:443/api/666/envelope/
    * [HTTP/2] [1] [:method: POST]
    * [HTTP/2] [1] [:scheme: https]
    * [HTTP/2] [1] [:authority: o167200.ingest.us.sentry.io]
    * [HTTP/2] [1] [:path: /api/4508799326420993/envelope/]
    * [HTTP/2] [1] [user-agent: sentry.native/0.8.4]
    * [HTTP/2] [1] [accept: */*]
    * [HTTP/2] [1] [x-sentry-auth: Sentry sentry_key=6666, sentry_version=7, sentry_client=sentry.native/0.8.4]
    * [HTTP/2] [1] [content-type: application/x-sentry-envelope]
    * [HTTP/2] [1] [content-length: 220869]
    > POST /api/4508799326420993/envelope/ HTTP/2
    Host: o167200.ingest.us.sentry.io
    User-Agent: sentry.native/0.8.4
    Accept: */*
    x-sentry-auth:Sentry sentry_key=666, sentry_version=7, sentry_client=sentry.native/0.8.4
    content-type:application/x-sentry-envelope
    content-length:220869
    
    * upload completely sent off: 220869 bytes
    < HTTP/2 200 
    < server: nginx
    < date: Fri, 18 Apr 2025 09:07:51 GMT
    < content-type: application/json
    < content-length: 41
    < vary: origin, access-control-request-method, access-control-request-headers
    < access-control-allow-origin: *
    < access-control-expose-headers: x-sentry-error,x-sentry-rate-limits,retry-after
    < cross-origin-resource-policy: cross-origin
    < strict-transport-security: max-age=31536000; includeSubDomains; preload
    < via: 1.1 google
    < alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
    < 
    {"id":"ab14f412504747852e71465a267899f7"}* Connection #0 to host o167200.ingest.us.sentry.io left intact
    
  6. supervacuus commented on Apr 20, 2025

    @supervacuus
    Collaborator

    TLDR: this is not a bug, but an essential difference between breakpad and crashpad (or any external crash handler) on macOS and one of the reasons why crashpad is still the preferred backend on macOS (even though there are distribution complexities due to the handler).

    Can you explain what you are trying to achieve by sending synthetic fatal signals? Do you primarily use this for testing, or are you relying on it in your production setup?

    I'm testing Sentry-native and Breakpad on my macOS machine. I've found that if I introduce a pointer access violation or send a SIGABRT signal, crash reports are successfully sent to the Sentry website. However, when I send a SIGSEGV signal to my program, although the crash information is visible in the local macOS console, no crash information is sent to the remote Sentry website.

    This is expected behavior for breakpad or any in-process handler that primarily relies on Mach exception handling. The signals you are trying to send aren't usually coming from another process, but from the kernel, and with them a crash-context (ucontext) that contains all the essential information to allow a crash handler to create a report. If you send a SIGSEGV from another process, there is no data for the handler to act on.

    In addition to that, and more importantly in your case, a synthetic POSIX signal sent to a macOS process, bypasses the Mach exception port listener, which is the listener used by all handlers on macOS (except for the inproc backend); it would have to be handled by a signal handler. The reason for this is that while macOS supports POSIX signals, they are implemented through a compatibility layer; at its core, the kernel emits Mach exceptions.

    In any handler setup for a particular process, the kernel would first emit a Mach exception, and only if convertible and signal handlers are present, emit a signal second. Suppose you send a synthetic crash signal (like the ones you mentioned) from another process. In that case, there is nothing to report to the Mach exception port listener because the signal originates from another process, not as a converted Mach exception from the kernel. Since no signal handlers exist, the signal would end up in the default handler, leading to the signal log that you see, but no crash report from breakpad.

    Previously, when I was using crashpad_handler, SIGSEGV signals were correctly sending crash information to Sentry.

    crashpad also doesn't register a signal handler on macOS, but it is still able to retrieve the unhandled signal. This touches on a subtle difference in handling and conversion between POSIX signals and Mach exceptions on macOS. Independent from where it originated, once a terminal signal passes through the process unhandled (i.e., the process would terminate), macOS converts the signal, during process exit, back into a EXC_CRASH exception and delivers this Mach exception to any remaining port listener, besides in-process listeners.

    That is one of the essential upsides of using crashpad on macOS: its listener runs inside the crashpad_handler (outside the monitored process), which receives that exception and then snapshots the crashed process at the last chance it can get. Whereas with breakpad, the in-process handler wouldn't receive anything.

    The only thing I've noticed is that when the SIGSEGV signal occurs, the content length of the crash information being sent is very short, only around 300 bytes. Normal crash information is usually over 100,000 bytes. Can you please help me analyze this? Thank you very much.

    What you are seeing is only a session request. No crash envelope is being sent.

  7. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Apr 20, 2025
  8. moved this to Waiting for: Community in GitHub Issues with 👀 3on Apr 20, 2025
  9. zongyangbigpolo commented on Apr 21, 2025

    @zongyangbigpolo
    Author

    Thank you so much for your comprehensive and detailed answer, it has been extremely helpful to me.

  10. moved this from Waiting for: Community to Waiting for: Product Owner in GitHub Issues with 👀 3on Apr 21, 2025
  11. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Apr 21, 2025
  12. supervacuus commented on Apr 21, 2025

    @supervacuus
    Collaborator

    Thank you so much for your comprehensive and detailed answer, it has been extremely helpful to me.

    I am happy to hear. Please let me know if you have any further questions.

  13. reopened this on Apr 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions