Skip to content

feat(crashtracking): retrieve c assert message for linux when __assert_fail is dynamically loaded#2268

Open
gyuheon0h wants to merge 1 commit into
mainfrom
gyuheon0h/PROF-15482-c-assert-msg
Open

feat(crashtracking): retrieve c assert message for linux when __assert_fail is dynamically loaded#2268
gyuheon0h wants to merge 1 commit into
mainfrom
gyuheon0h/PROF-15482-c-assert-msg

Conversation

@gyuheon0h

@gyuheon0h gyuheon0h commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

When a process crashes due to a C assert() failure, the crash report now includes the assertion expression string (Assertion failed: (x > 0), function foo, file bar.c, line 42) in error.message, instead of just reporting a bare SIGABRT.

When a shared library calls an external function like __assert_fail, it doesn't jump directly to the target. Instead, it jumps through the global offset table. Every shared library has its own GOT with its own slot for each external function it calls.
We overwrites the slots at runtime for __assert_fail so calls are redirected to our hook function. My initial thought was to use LD_PRELOAD but this approach works no matter the load order.

I was inspired by libdd-profiling-heap-gotter which does something similar to intercept malloc/free for heap profiling.

During crashtracker::init(), install_assert_hook()

  1. Resolves the original assertion handler
  2. Enumerate loaded ELF objects
  3. Inspect dynamic relocation tables
  4. parses each object’s PT_DYNAMIC segment to locate its relocation tables
  5. Patch references to __assert_fail

When a C assert() fails:
The hook captures the assertion expression, file name, line no, func name, and stores it through an atomic pointer:

  1. The hook calls the original __assert_fail() implementation.
  2. The original implementation calls abort(), which raises SIGABRT.
  3. The crashtracker signal handler checks the stored assertion metadata
  4. The assertion details are included in the resulting crash report.

Unfortunately, this doesn't work everywhere

  • Linux 64-bit (glibc): Full support with GOT patching.
  • Linux 64-bit (musl/Alpine): Best-effort since if libc is statically linked, __assert_fail has no GOT entry to patch. The hook installs silently as a no-op.
  • Other platforms: No-op. install_assert_hook() compiles to an empty function.

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

How to test the change?

{
  "counters": {
    "profiler_collecting_sample": 1,
    "profiler_inactive": 0,
    "profiler_serializing": 0,
    "profiler_unwinding": 0
  },
  "data_schema_version": "1.8",
  "error": {
    "is_crash": true,
    "kind": "UnixSignal",
    "message": "Assertion failed: (test_value > 0), function test_function, file test_file.c, line 42.",
    "source_type": "Crashtracking",
    "stack": {
      "format": "Datadog Crashtracker 1.0",
      "frames": [
        {
          "build_id": "4f7b0c955c3d81d7cac1501a2498b69d1d82bfe7",
          "build_id_type": "GNU",
          "column": 10,
          "file": "./nptl/pthread_kill.c",
          "file_type": "ELF",
          "function": "__GI___pthread_kill",
          "ip": "0x7533a749c9fc",
          "line": 89,
          "module_base_address": "0x7533a7406000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x00000000000969fc",
          "sp": "0x7ffe7addd7e0",
          "symbol_address": "0x7533a749c8d0"
        },
        {
          "build_id": "4f7b0c955c3d81d7cac1501a2498b69d1d82bfe7",
          "build_id_type": "GNU",
          "column": 6,
          "file": "./signal/../sysdeps/posix/raise.c",
          "file_type": "ELF",
          "function": "__GI_raise",
          "ip": "0x7533a7448476",
          "line": 27,
          "module_base_address": "0x7533a7406000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x0000000000042476",
          "sp": "0x7ffe7addd8a0",
          "symbol_address": "0x7533a7448460"
        },
        {
          "build_id": "4f7b0c955c3d81d7cac1501a2498b69d1d82bfe7",
          "build_id_type": "GNU",
          "column": 7,
          "file": "./stdlib/abort.c",
          "file_type": "ELF",
          "function": "__GI_abort",
          "ip": "0x7533a742e7f3",
          "line": 81,
          "module_base_address": "0x7533a7406000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x00000000000287f3",
          "sp": "0x7ffe7addd8b0",
          "symbol_address": "0x7533a742e720"
        },
        {
          "build_id": "4f7b0c955c3d81d7cac1501a2498b69d1d82bfe7",
          "build_id_type": "GNU",
          "column": 9,
          "file": "./intl/loadmsgcat.c",
          "file_type": "ELF",
          "function": "_nl_load_domain",
          "ip": "0x7533a742e71b",
          "line": 1177,
          "module_base_address": "0x7533a7406000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x000000000002871b",
          "sp": "0x7ffe7addd9f0"
        },
        {
          "build_id": "4f7b0c955c3d81d7cac1501a2498b69d1d82bfe7",
          "build_id_type": "GNU",
          "comments": [
            "resolve_names failed with Couldn't symbolize 128864710033046: address not found in symbolization source"
          ],
          "file_type": "ELF",
          "ip": "0x7533a743fe96",
          "module_base_address": "0x7533a7406000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x0000000000039e96",
          "sp": "0x7ffe7addda40"
        },
        {
          "build_id": "2e13b5f6a8ed08eac37b6666aa498b353d10f004",
          "build_id_type": "GNU",
          "column": 5,
          "file": "/home/bits/go/src/github.com/DataDog/libdatadog/libdd-crashtracker/src/collector/assert_interceptor.rs",
          "file_type": "ELF",
          "function": "hook_assert_fail",
          "ip": "0x56fa7950cd16",
          "line": 91,
          "module_base_address": "0x56fa794be000",
          "path": "/home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
          "relative_address": "0x000000000004ed16",
          "sp": "0x7ffe7addda70"
        },
        {
          "build_id": "2e13b5f6a8ed08eac37b6666aa498b353d10f004",
          "build_id_type": "GNU",
          "column": 5,
          "file": "/home/bits/go/src/github.com/DataDog/libdatadog/bin_tests/src/bin/crashtracker_bin_test.rs",
          "file_type": "ELF",
          "function": "main",
          "ip": "0x56fa794ebf46",
          "line": 9,
          "module_base_address": "0x56fa794be000",
          "path": "/home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
          "relative_address": "0x000000000002df46",
          "sp": "0x7ffe7adddb50"
        },
        {
          "build_id": "2e13b5f6a8ed08eac37b6666aa498b353d10f004",
          "build_id_type": "GNU",
          "column": 2,
          "file": "/home/bits/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys/backtrace.rs",
          "file_type": "ELF",
          "function": "__rust_begin_short_backtrace<fn() -> core::result::Result<(), anyhow::Error>, core::result::Result<(), anyhow::Error>>",
          "ip": "0x56fa794ec809",
          "line": 172,
          "module_base_address": "0x56fa794be000",
          "path": "/home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
          "relative_address": "0x000000000002e809",
          "sp": "0x7ffe7adde350"
        },
        {
          "build_id": "2e13b5f6a8ed08eac37b6666aa498b353d10f004",
          "build_id_type": "GNU",
          "file_type": "ELF",
          "function": "main",
          "ip": "0x56fa794edca9",
          "module_base_address": "0x56fa794be000",
          "path": "/home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
          "relative_address": "0x000000000002fca9",
          "sp": "0x7ffe7adde360"
        },
        {
          "build_id": "4f7b0c955c3d81d7cac1501a2498b69d1d82bfe7",
          "build_id_type": "GNU",
          "column": 16,
          "file": "./csu/../sysdeps/nptl/libc_start_call_main.h",
          "file_type": "ELF",
          "function": "__libc_start_call_main",
          "ip": "0x7533a742fd90",
          "line": 58,
          "module_base_address": "0x7533a7406000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x0000000000029d90",
          "sp": "0x7ffe7adde460"
        },
        {
          "build_id": "4f7b0c955c3d81d7cac1501a2498b69d1d82bfe7",
          "build_id_type": "GNU",
          "column": 5,
          "file": "./csu/../csu/libc-start.c",
          "file_type": "ELF",
          "function": "__libc_start_main_impl",
          "ip": "0x7533a742fe40",
          "line": 379,
          "module_base_address": "0x7533a7406000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x0000000000029e40",
          "sp": "0x7ffe7adde500",
          "symbol_address": "0x7533a742fdc0"
        },
        {
          "build_id": "2e13b5f6a8ed08eac37b6666aa498b353d10f004",
          "build_id_type": "GNU",
          "file_type": "ELF",
          "function": "_start",
          "ip": "0x56fa794eaad5",
          "module_base_address": "0x56fa794be000",
          "path": "/home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
          "relative_address": "0x000000000002cad5",
          "sp": "0x7ffe7adde550"
        }
      ],
      "incomplete": false
    },
    "thread_name": "crashtracker_bi"
  },
  "experimental": {},
  "files": {
    "/proc/self/maps": [
      "56fa794be000-56fa794ea000 r--p 00000000 103:03 19150680                  /home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
      "56fa794ea000-56fa79557000 r-xp 0002b000 103:03 19150680                  /home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
      ...
      "56fa79557000-56fa7955e000 r--p 00097000 103:03 19150680      
      "7ffe7adef000-7ffe7adf3000 r--p 00000000 00:00 0                          [vvar]",
      "7ffe7adf3000-7ffe7adf5000 r-xp 00000000 00:00 0                          [vdso]",
      "ffffffffff600000-ffffffffff601000 --xp 00000000 00:00 0                  [vsyscall]",
      ""
    ]
  },
  "incomplete": false,
  "log_messages": [
    "Error resolving frames: normalize_ips: Ok(())\tresolve_names: Err(Failed to resolve names, see frame comments for details)"
  ],
  "metadata": {
    "family": "native",
    "library_name": "libdatadog",
    "library_version": "1.0.0",
    "tags": [
      "service:foo",
      "service_version:bar",
      "runtime-id:xyz",
      "language:native"
    ]
  },
  "os_info": {
    "architecture": "x86_64",
    "bitness": "64-bit",
    "os_type": "Ubuntu",
    "version": "22.4.0"
  },
  "proc_info": {
    "pid": 1582699,
    "tid": 1582699
  },
  "sig_info": {
    "si_code": -6,
    "si_code_human_readable": "SI_TKILL",
    "si_signo": 6,
    "si_signo_human_readable": "SIGABRT"
  },
  "timestamp": "2026-07-23 16:30:18.414200603 UTC",
  "ucontext": {
    "arch": "x86_64",
    "raw": "ucontext_t { uc_flags: 7, uc_link: 0x0, uc_stack: stack_t { ss_sp: 0x7533a73f4000, ss_flags: 0, ss_size: 65536 }, uc_mcontext: mcontext_t { gregs: [140730959780016, 0, 8, 582, 6, 22, 95633776894021, 42, 1582699, 1582699, 1582699, 128864709791808, 6, 0, 128864710412796, 140730959779808, 128864710412796, 582, 12103423998558259, 0, 0, 0, 0], fpregs: 0x7533a7403540, __private: [0, 0, 0, 0, 0, 0, 0, 0] }, uc_sigmask: sigset_t { __val: [0, 6, 4294967290, 4294968878699, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] }, __private: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 128, 31, 0, 0, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 23, 98, 167, 51, 117, 0, 0, 35, 23, 98, 167, 51, 117, 0, 0, 36, 23, 98, 167, 51, 117, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 127, 20, 129, 250, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 127, 20, 129, 250, 86, 0, 0, 224, 127, 20, 129, 250, 86, 0, 0, 68, 128, 20, 129, 250, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 224, 12, 98, 167, 51, 117, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 208, 216, 221, 122, 254, 127, 0, 0, 29, 0, 0, 0, 15, 0, 0, 0, 232, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0, 100, 100, 45, 108, 105, 98, 117, 110, 119, 105, 110, 100, 45, 115, 121, 115, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 88, 80, 70, 140, 10, 0, 0, 255, 2, 0, 0, 0, 0, 0, 0, 136, 10, 0, 0, 0, 0, 0, 0], __ssp: [0, 0, 0, 675] }",
    "registers": {
      "r10": "0x0000000000000008",
      "r11": "0x0000000000000246",
      "r12": "0x0000000000000006",
      "r13": "0x0000000000000016",
      "r14": "0x000056fa794ce045",
      "r15": "0x000000000000002a",
      "r8": "0x00007ffe7addd8b0",
      "r9": "0x0000000000000000",
      "rax": "0x0000000000000000",
      "rbp": "0x000000000018266b",
      "rbx": "0x00007533a7405040",
      "rcx": "0x00007533a749c9fc",
      "rdi": "0x000000000018266b",
      "rdx": "0x0000000000000006",
      "rip": "0x00007533a749c9fc",
      "rsi": "0x000000000018266b",
      "rsp": "0x00007ffe7addd7e0"
    }
  },
  "uuid": "9234251d-9df8-4d57-84b1-06e7268b05a6"
}

Copy link
Copy Markdown
Contributor Author

@gyuheon0h gyuheon0h changed the title Use GOT patching to retrieve c assert message feat(crashtracking): retrieve c assert message Jul 23, 2026
@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

📚 Documentation Check Results

⚠️ 2795 documentation warning(s) found

📦 bin_tests - 1694 warning(s)

📦 libdd-crashtracker - 1101 warning(s)


Updated: 2026-07-23 18:30:47 UTC | Commit: 1fa01ef | missing-docs job results

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

🔒 Cargo Deny Results

⚠️ 6 issue(s) found, showing only errors (advisories, bans, sources)

📦 bin_tests - 4 error(s)

Show output
error[vulnerability]: Invalid pointer dereference in `fmt::Pointer` impl for `Atomic` and `Shared` when the underlying pointer is invalid
   ┌─ /home/runner/work/libdatadog/libdatadog/Cargo.lock:73:1
   │
73 │ crossbeam-epoch 0.9.18 registry+https://github.com/rust-lang/crates.io-index
   │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ security vulnerability detected
   │
   ├ ID: RUSTSEC-2026-0204
   ├ Advisory: https://rustsec.org/advisories/RUSTSEC-2026-0204
   ├ Affected versions of `fmt::Display` dereference the underlying pointer. This causes a invalid pointer dereference e.g., when a pointer created with `Atomic::null` or `Shared::null`. `fmt::Debug` impls and pre-0.9 `fmt::Display` impls, which do not dereference pointers, are not affected by this issue.
   ├ Announcement: https://github.com/crossbeam-rs/crossbeam/pull/1276
   ├ Solution: Upgrade to >=0.9.20 (try `cargo update -p crossbeam-epoch`)
   ├ crossbeam-epoch v0.9.18
     ├── crossbeam-deque v0.8.5
     │   └── rayon-core v1.12.1
     │       └── rayon v1.10.0
     │           └── criterion v0.5.1
     │               ├── (dev) libdd-crashtracker v1.0.0
     │               │   └── bin_tests v0.1.0
     │               ├── (dev) libdd-ddsketch v1.1.0
     │               │   └── libdd-telemetry v6.0.0
     │               │       └── libdd-crashtracker v1.0.0 (*)
     │               └── (dev) libdd-profiling v1.0.0
     │                   ├── bin_tests v0.1.0 (*)
     │                   └── (dev) libdd-profiling v1.0.0 (*)
     └── moka v0.12.13
         └── hickory-resolver v0.25.2
             └── reqwest v0.13.2
                 ├── libdd-common v5.1.0
                 │   ├── bin_tests v0.1.0 (*)
                 │   ├── libdd-capabilities-impl v3.0.0
                 │   │   ├── libdd-crashtracker v1.0.0 (*)
                 │   │   ├── libdd-shared-runtime v2.0.0
                 │   │   │   └── libdd-telemetry v6.0.0 (*)
                 │   │   └── (dev) libdd-telemetry v6.0.0 (*)
                 │   ├── (build) libdd-crashtracker v1.0.0 (*)
                 │   ├── libdd-profiling v1.0.0 (*)
                 │   ├── libdd-shared-runtime v2.0.0 (*)
                 │   └── libdd-telemetry v6.0.0 (*)
                 └── libdd-profiling v1.0.0 (*)

error[vulnerability]: NSEC3 closest-encloser proof validation enters unbounded loop on cross-zone responses
    ┌─ /home/runner/work/libdatadog/libdatadog/Cargo.lock:124:1
    │
124 │ hickory-proto 0.25.2 registry+https://github.com/rust-lang/crates.io-index
    │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ security vulnerability detected
    │
    ├ ID: RUSTSEC-2026-0118
    ├ Advisory: https://rustsec.org/advisories/RUSTSEC-2026-0118
    ├ The NSEC3 closest-encloser proof validation in `hickory-proto`'s
      `DnssecDnsHandle` walks from the QNAME up to the SOA owner name, building a
      list of candidate encloser names. The iterator used assumes the
      QNAME is a descendant of the SOA owner, terminating only when the current
      candidate equals the SOA name. When the SOA in a response's authority section
      is not an ancestor of the QNAME, the loop stalls at the DNS root and never
      terminates, repeatedly calling `Name::base_name()` and pushing newly allocated
      `Name` and hashed-name entries into the candidate `Vec`.
      
      The bug is reachable by any caller of `DnssecDnsHandle` — including the
      resolver, recursor, and client — when built with the `dnssec-ring` or
      `dnssec-aws-lc-rs` feature and configured to perform DNSSEC validation. It is
      triggered while validating a NoData or NXDomain response whose authority
      section contains an SOA record from a zone other than an ancestor of the
      QNAME, on a code path that requires NSEC3 closest-encloser proof. In practice
      this can be reached through an insecure CNAME chain that crosses zone
      boundaries into a DNSSEC-signed zone returning NoData, but the minimum
      condition is just a mismatched SOA owner on a response requiring NSEC3
      validation.
      
      A `debug_assert_ne!(name, Name::root())` guards the loop body, so debug builds
      abort with a panic on the first iteration past the root. Release builds
      compile the assertion out and run the loop unbounded, allocating until the
      process exhausts available memory (OOM). A reachable upstream attacker who
      can return such a response can therefore crash a debug-built validator or
      exhaust memory on a release-built one.
      
      The affected code was migrated from `hickory-proto` to `hickory-net` as part of
      the 0.26.0 release. The `hickory-proto` 0.26.x release no longer offers
      `DnssecDnsHandle` and so we recommend all affected users update to `hickory-net`
      0.26.1 when the implementation of that type is required.
    ├ Announcement: https://github.com/hickory-dns/hickory-dns/security/advisories/GHSA-3v94-mw7p-v465
    ├ Solution: No safe upgrade is available!
    ├ hickory-proto v0.25.2
      └── hickory-resolver v0.25.2
          └── reqwest v0.13.2
              ├── libdd-common v5.1.0
              │   ├── bin_tests v0.1.0
              │   ├── libdd-capabilities-impl v3.0.0
              │   │   ├── libdd-crashtracker v1.0.0
              │   │   │   └── bin_tests v0.1.0 (*)
              │   │   ├── libdd-shared-runtime v2.0.0
              │   │   │   └── libdd-telemetry v6.0.0
              │   │   │       └── libdd-crashtracker v1.0.0 (*)
              │   │   └── (dev) libdd-telemetry v6.0.0 (*)
              │   ├── (build) libdd-crashtracker v1.0.0 (*)
              │   ├── libdd-profiling v1.0.0
              │   │   ├── bin_tests v0.1.0 (*)
              │   │   └── (dev) libdd-profiling v1.0.0 (*)
              │   ├── libdd-shared-runtime v2.0.0 (*)
              │   └── libdd-telemetry v6.0.0 (*)
              └── libdd-profiling v1.0.0 (*)

error[vulnerability]: CPU exhaustion during message encoding due to O(n²) name compression
    ┌─ /home/runner/work/libdatadog/libdatadog/Cargo.lock:124:1
    │
124 │ hickory-proto 0.25.2 registry+https://github.com/rust-lang/crates.io-index
    │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ security vulnerability detected
    │
    ├ ID: RUSTSEC-2026-0119
    ├ Advisory: https://rustsec.org/advisories/RUSTSEC-2026-0119
    ├ During message encoding, `hickory-proto`'s `BinEncoder` stores pointers to
      labels that are candidates for name compression in a `Vec<(usize, Vec<u8>)>`.
      The name compression logic then searches for matches with a linear scan.
      
      A malicious message with many records can both introduce many candidate labels,
      and invoke this linear scan many times. This can amplify CPU exhaustion in DoS
      attacks.
      
      This is similar to
      [CVE-2024-8508](https://www.nlnetlabs.nl/downloads/unbound/CVE-2024-8508.txt).
      
      We recommend all affected users update to `hickory-proto` 0.26.1 for the fix.
    ├ Announcement: https://github.com/hickory-dns/hickory-dns/security/advisories/GHSA-q2qq-hmj6-3wpp
    ├ Solution: Upgrade to >=0.26.1 (try `cargo update -p hickory-proto`)
    ├ hickory-proto v0.25.2
      └── hickory-resolver v0.25.2
          └── reqwest v0.13.2
              ├── libdd-common v5.1.0
              │   ├── bin_tests v0.1.0
              │   ├── libdd-capabilities-impl v3.0.0
              │   │   ├── libdd-crashtracker v1.0.0
              │   │   │   └── bin_tests v0.1.0 (*)
              │   │   ├── libdd-shared-runtime v2.0.0
              │   │   │   └── libdd-telemetry v6.0.0
              │   │   │       └── libdd-crashtracker v1.0.0 (*)
              │   │   └── (dev) libdd-telemetry v6.0.0 (*)
              │   ├── (build) libdd-crashtracker v1.0.0 (*)
              │   ├── libdd-profiling v1.0.0
              │   │   ├── bin_tests v0.1.0 (*)
              │   │   └── (dev) libdd-profiling v1.0.0 (*)
              │   ├── libdd-shared-runtime v2.0.0 (*)
              │   └── libdd-telemetry v6.0.0 (*)
              └── libdd-profiling v1.0.0 (*)

error[unsound]: Rand is unsound with a custom logger using `rand::rng()`
    ┌─ /home/runner/work/libdatadog/libdatadog/Cargo.lock:241:1
    │
241 │ rand 0.8.5 registry+https://github.com/rust-lang/crates.io-index
    │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ unsound advisory detected
    │
    ├ ID: RUSTSEC-2026-0097
    ├ Advisory: https://rustsec.org/advisories/RUSTSEC-2026-0097
    ├ It has been reported (by [@lopopolo](https://github.com/lopopolo)) that the `rand` library is [unsound](https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#soundness-of-code--of-a-library) (i.e. that safe code using the public API can cause Undefined Behaviour) when all the following conditions are met:
      
      - The `log` and `thread_rng` features are enabled
      - A [custom logger](https://docs.rs/log/latest/log/#implementing-a-logger) is defined
      - The custom logger accesses `rand::rng()` (previously `rand::thread_rng()`) and calls any `TryRng` (previously `RngCore`) methods on `ThreadRng`
      - The `ThreadRng` (attempts to) reseed while called from the custom logger (this happens every 64 kB of generated data)
      - Trace-level logging is enabled or warn-level logging is enabled and the random source (the `getrandom` crate) is unable to provide a new seed
      
      `TryRng` (previously `RngCore`) methods for `ThreadRng` use `unsafe` code to cast `*mut BlockRng<ReseedingCore>` to `&mut BlockRng<ReseedingCore>`. When all the above conditions are met this results in an aliased mutable reference, violating the Stacked Borrows rules. Miri is able to detect this violation in sample code. Since construction of [aliased mutable references is Undefined Behaviour](https://doc.rust-lang.org/stable/nomicon/references.html), the behaviour of optimized builds is hard to predict.
    ├ Announcement: https://github.com/rust-random/rand/pull/1763
    ├ Solution: Upgrade to >=0.10.1 OR <0.10.0, >=0.9.3 OR <0.9.0, >=0.8.6 (try `cargo update -p rand`)
    ├ rand v0.8.5
      ├── (dev) libdd-common v5.1.0
      │   ├── bin_tests v0.1.0
      │   ├── libdd-capabilities-impl v3.0.0
      │   │   ├── libdd-crashtracker v1.0.0
      │   │   │   └── bin_tests v0.1.0 (*)
      │   │   ├── libdd-shared-runtime v2.0.0
      │   │   │   └── libdd-telemetry v6.0.0
      │   │   │       └── libdd-crashtracker v1.0.0 (*)
      │   │   └── (dev) libdd-telemetry v6.0.0 (*)
      │   ├── (build) libdd-crashtracker v1.0.0 (*)
      │   ├── libdd-profiling v1.0.0
      │   │   ├── bin_tests v0.1.0 (*)
      │   │   └── (dev) libdd-profiling v1.0.0 (*)
      │   ├── libdd-shared-runtime v2.0.0 (*)
      │   └── libdd-telemetry v6.0.0 (*)
      ├── libdd-crashtracker v1.0.0 (*)
      ├── (dev) libdd-ddsketch v1.1.0
      │   └── libdd-telemetry v6.0.0 (*)
      ├── libdd-profiling v1.0.0 (*)
      └── proptest v1.5.0
          └── (dev) libdd-profiling v1.0.0 (*)

advisories FAILED, bans ok, sources ok

📦 libdd-crashtracker - 2 error(s)

Show output
error[vulnerability]: Invalid pointer dereference in `fmt::Pointer` impl for `Atomic` and `Shared` when the underlying pointer is invalid
   ┌─ /home/runner/work/libdatadog/libdatadog/Cargo.lock:59:1
   │
59 │ crossbeam-epoch 0.9.18 registry+https://github.com/rust-lang/crates.io-index
   │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ security vulnerability detected
   │
   ├ ID: RUSTSEC-2026-0204
   ├ Advisory: https://rustsec.org/advisories/RUSTSEC-2026-0204
   ├ Affected versions of `fmt::Display` dereference the underlying pointer. This causes a invalid pointer dereference e.g., when a pointer created with `Atomic::null` or `Shared::null`. `fmt::Debug` impls and pre-0.9 `fmt::Display` impls, which do not dereference pointers, are not affected by this issue.
   ├ Announcement: https://github.com/crossbeam-rs/crossbeam/pull/1276
   ├ Solution: Upgrade to >=0.9.20 (try `cargo update -p crossbeam-epoch`)
   ├ crossbeam-epoch v0.9.18
     └── crossbeam-deque v0.8.5
         └── rayon-core v1.12.1
             └── rayon v1.10.0
                 └── criterion v0.5.1
                     ├── (dev) libdd-crashtracker v1.0.0
                     └── (dev) libdd-ddsketch v1.1.0
                         └── libdd-telemetry v6.0.0
                             └── libdd-crashtracker v1.0.0 (*)

error[unsound]: Rand is unsound with a custom logger using `rand::rng()`
    ┌─ /home/runner/work/libdatadog/libdatadog/Cargo.lock:204:1
    │
204 │ rand 0.8.5 registry+https://github.com/rust-lang/crates.io-index
    │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ unsound advisory detected
    │
    ├ ID: RUSTSEC-2026-0097
    ├ Advisory: https://rustsec.org/advisories/RUSTSEC-2026-0097
    ├ It has been reported (by [@lopopolo](https://github.com/lopopolo)) that the `rand` library is [unsound](https://rust-lang.github.io/unsafe-code-guidelines/glossary.html#soundness-of-code--of-a-library) (i.e. that safe code using the public API can cause Undefined Behaviour) when all the following conditions are met:
      
      - The `log` and `thread_rng` features are enabled
      - A [custom logger](https://docs.rs/log/latest/log/#implementing-a-logger) is defined
      - The custom logger accesses `rand::rng()` (previously `rand::thread_rng()`) and calls any `TryRng` (previously `RngCore`) methods on `ThreadRng`
      - The `ThreadRng` (attempts to) reseed while called from the custom logger (this happens every 64 kB of generated data)
      - Trace-level logging is enabled or warn-level logging is enabled and the random source (the `getrandom` crate) is unable to provide a new seed
      
      `TryRng` (previously `RngCore`) methods for `ThreadRng` use `unsafe` code to cast `*mut BlockRng<ReseedingCore>` to `&mut BlockRng<ReseedingCore>`. When all the above conditions are met this results in an aliased mutable reference, violating the Stacked Borrows rules. Miri is able to detect this violation in sample code. Since construction of [aliased mutable references is Undefined Behaviour](https://doc.rust-lang.org/stable/nomicon/references.html), the behaviour of optimized builds is hard to predict.
    ├ Announcement: https://github.com/rust-random/rand/pull/1763
    ├ Solution: Upgrade to >=0.10.1 OR <0.10.0, >=0.9.3 OR <0.9.0, >=0.8.6 (try `cargo update -p rand`)
    ├ rand v0.8.5
      ├── libdd-common v5.1.0
      │   ├── libdd-capabilities-impl v3.0.0
      │   │   ├── libdd-crashtracker v1.0.0
      │   │   ├── libdd-shared-runtime v2.0.0
      │   │   │   └── libdd-telemetry v6.0.0
      │   │   │       └── libdd-crashtracker v1.0.0 (*)
      │   │   └── (dev) libdd-telemetry v6.0.0 (*)
      │   ├── (build) libdd-crashtracker v1.0.0 (*)
      │   ├── libdd-shared-runtime v2.0.0 (*)
      │   └── libdd-telemetry v6.0.0 (*)
      ├── libdd-crashtracker v1.0.0 (*)
      └── (dev) libdd-ddsketch v1.1.0
          └── libdd-telemetry v6.0.0 (*)

advisories FAILED, bans ok, sources ok

Updated: 2026-07-23 18:30:27 UTC | Commit: 1fa01ef | dependency-check job results

@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch from f3e6979 to 6e7f47d Compare July 23, 2026 16:42
@pr-commenter

pr-commenter Bot commented Jul 23, 2026

Copy link
Copy Markdown

Benchmarks

Comparison

Benchmark execution time: 2026-07-23 18:36:40

Comparing candidate commit 7568fed in PR branch gyuheon0h/PROF-15482-c-assert-msg with baseline commit 15899df in branch main.

Found 0 performance improvements and 1 performance regressions! Performance is the same for 0 metrics, 0 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:receiver_entry_point/report/2644

  • 🟥 execution_time [+177.159µs; +190.286µs] or [+5.297%; +5.690%]

Candidate

Candidate benchmark details

Group 1

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 7568fed 1784831316 gyuheon0h/PROF-15482-c-assert-msg
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
receiver_entry_point/report/2644 execution_time 3.488ms 3.528ms ± 0.033ms 3.518ms ± 0.010ms 3.529ms 3.604ms 3.650ms 3.693ms 4.96% 2.409 6.445 0.94% 0.002ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
receiver_entry_point/report/2644 execution_time [3.524ms; 3.533ms] or [-0.131%; +0.131%] None None None

Baseline

Baseline benchmark details

Group 1

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8259CL CPU @ 2.50GHz 15899df 1784828029 main
scenario metric min mean ± sd median ± mad p75 p95 p99 max peak_to_median_ratio skewness kurtosis cv sem runs sample_size
receiver_entry_point/report/2644 execution_time 3.311ms 3.345ms ± 0.034ms 3.334ms ± 0.009ms 3.345ms 3.433ms 3.449ms 3.467ms 4.02% 1.981 3.034 1.00% 0.002ms 1 200
scenario metric 95% CI mean Shapiro-Wilk pvalue Ljung-Box pvalue (lag=1) Dip test pvalue
receiver_entry_point/report/2644 execution_time [3.340ms; 3.349ms] or [-0.139%; +0.139%] None None None

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Jul 23, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 81.20%
Overall Coverage: 74.66% (+0.01%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 7568fed | Docs | Datadog PR Page | Give us feedback!

@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch 2 times, most recently from 13ad896 to 28b571f Compare July 23, 2026 17:13
@gyuheon0h gyuheon0h changed the title feat(crashtracking): retrieve c assert message feat(crashtracking): retrieve c assert message when __assert_fail is dynamically loaded Jul 23, 2026
@gyuheon0h gyuheon0h changed the title feat(crashtracking): retrieve c assert message when __assert_fail is dynamically loaded feat(crashtracking): retrieve c assert message for linux when __assert_fail is dynamically loaded Jul 23, 2026
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch from 28b571f to 6b2f473 Compare July 23, 2026 18:19
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch from 6b2f473 to 7568fed Compare July 23, 2026 18:28
@dd-octo-sts

dd-octo-sts Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 88.18 MB 88.27 MB +.10% (+90.62 KB) 🔍
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 8.13 MB 8.13 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.93 MB 10.93 MB +.01% (+1.92 KB) 🔍
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 99.46 MB 99.55 MB +.09% (+92.25 KB) 🔍
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 26.59 MB 26.59 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 89.18 KB 89.18 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 191.42 MB 191.39 MB --.01% (-32.00 KB) 💪
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 1.04 GB 1.04 GB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.66 MB 8.66 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 89.18 KB 89.18 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 25.36 MB 25.36 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 50.56 MB 50.56 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 23.16 MB 23.16 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 90.58 KB 90.58 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 196.09 MB 196.08 MB -0% (-16.00 KB) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 1.03 GB 1.03 GB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.68 MB 6.68 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 90.58 KB 90.58 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 27.26 MB 27.26 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 48.13 MB 48.13 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 78.65 MB 78.73 MB +.11% (+89.04 KB) 🔍
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 9.06 MB 9.07 MB +.12% (+12.00 KB) 🔍
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 94.14 MB 94.23 MB +.09% (+90.13 KB) 🔍
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 11.02 MB 11.03 MB +.04% (+5.53 KB) 🔍

@gyuheon0h
gyuheon0h marked this pull request as ready for review July 24, 2026 20:45
@gyuheon0h
gyuheon0h requested a review from a team as a code owner July 24, 2026 20:45

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7568fed720

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

let guard_ptr = &mut guard as *mut PageProtGuard;
let patched_ptr = &mut patched_any as *mut bool;

iterate_libraries(|info| {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Re-scan libraries loaded after init

In runtimes that dlopen native extensions after crashtracker::init, this one-time dl_iterate_phdr pass only patches the libraries that are already loaded, and there is no dlopen hook or assert-hook update path elsewhere in the repo. A later-loaded extension gets its own __assert_fail PLT/GOT entry pointing directly at libc, so its C assert() failures still report as a bare SIGABRT instead of carrying the assertion text; the hook needs to be applied on later loads as well. This matters for libdatadog’s FFI runtime integrations.

AGENTS.md reference: AGENTS.md:L70-L74

Useful? React with 👍 / 👎.

Receiver::update_stored_config(receiver_config)?;
register_crash_handlers(&config)?;
register_panic_hook()?;
install_assert_hook()?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip the assert hook when SIGABRT is not tracked

When callers configure crashtracker without SIGABRT (for example, only SIGSEGV), this still installs a process-wide GOT hook for __assert_fail even though the registered signal handlers above will not handle the abort. That changes every loaded module's C assert path and allocates in the hook while providing no crash report, so the hook should be guarded on config.signals().contains(&libc::SIGABRT) or a separate explicit opt-in.

AGENTS.md reference: AGENTS.md:L70-L74

Useful? React with 👍 / 👎.

Comment on lines +132 to +133
if strtab.is_null() || symtab.is_null() || gnu_hash.is_null() {
return None;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Handle SysV-only hash tables

When a loaded object was linked with --hash-style=sysv and has DT_HASH but no DT_GNU_HASH, this early return skips its relocation tables entirely. Such objects can still have __assert_fail PLT relocations, so their C asserts bypass the hook and keep producing a bare SIGABRT even when the library was loaded before init; please parse DT_HASH or use another bounded dynsym fallback instead of requiring GNU hash.

AGENTS.md reference: AGENTS.md:L70-L74

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant