Skip to content

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

Draft
gyuheon0h wants to merge 1 commit into
gyuheon0h/got-hook-utilsfrom
gyuheon0h/PROF-15482-c-assert-msg
Draft

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

Conversation

@gyuheon0h

@gyuheon0h gyuheon0h commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Stacked above: feat(got-hook): add DT_HASH fallback, relocation type guard, and hook_symbol

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 trigger_c_assert, file src/c/trigger_assert.c, line 12.",
    "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": "0x727c09d7b9fc",
          "line": 89,
          "module_base_address": "0x727c09ce5000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x00000000000969fc",
          "sp": "0x7ffc91dce470",
          "symbol_address": "0x727c09d7b8d0"
        },
        {
          "build_id": "4f7b0c955c3d81d7cac1501a2498b69d1d82bfe7",
          "build_id_type": "GNU",
          "column": 6,
          "file": "./signal/../sysdeps/posix/raise.c",
          "file_type": "ELF",
          "function": "__GI_raise",
          "ip": "0x727c09d27476",
          "line": 27,
          "module_base_address": "0x727c09ce5000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x0000000000042476",
          "sp": "0x7ffc91dce530",
          "symbol_address": "0x727c09d27460"
        },
        {
          "build_id": "4f7b0c955c3d81d7cac1501a2498b69d1d82bfe7",
          "build_id_type": "GNU",
          "column": 7,
          "file": "./stdlib/abort.c",
          "file_type": "ELF",
          "function": "__GI_abort",
          "ip": "0x727c09d0d7f3",
          "line": 81,
          "module_base_address": "0x727c09ce5000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x00000000000287f3",
          "sp": "0x7ffc91dce540",
          "symbol_address": "0x727c09d0d720"
        },
        {
          "build_id": "4f7b0c955c3d81d7cac1501a2498b69d1d82bfe7",
          "build_id_type": "GNU",
          "column": 9,
          "file": "./intl/loadmsgcat.c",
          "file_type": "ELF",
          "function": "_nl_load_domain",
          "ip": "0x727c09d0d71b",
          "line": 1177,
          "module_base_address": "0x727c09ce5000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x000000000002871b",
          "sp": "0x7ffc91dce680"
        },
        {
          "build_id": "4f7b0c955c3d81d7cac1501a2498b69d1d82bfe7",
          "build_id_type": "GNU",
          "comments": [
            "resolve_names failed with Couldn't symbolize 125877066264214: address not found in symbolization source"
          ],
          "file_type": "ELF",
          "ip": "0x727c09d1ee96",
          "module_base_address": "0x727c09ce5000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x0000000000039e96",
          "sp": "0x7ffc91dce6d0"
        },
        {
          "build_id": "a7ba23793697db2e70bfbe6648326398eed71003",
          "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": "0x63a727372d46",
          "line": 92,
          "module_base_address": "0x63a727324000",
          "path": "/home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
          "relative_address": "0x000000000004ed46",
          "sp": "0x7ffc91dce700"
        },
        {
          "build_id": "a7ba23793697db2e70bfbe6648326398eed71003",
          "build_id_type": "GNU",
          "file_type": "ELF",
          "function": "trigger_c_assert",
          "ip": "0x63a7273b319b",
          "module_base_address": "0x63a727324000",
          "path": "/home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
          "relative_address": "0x000000000008f19b",
          "sp": "0x7ffc91dce7e0"
        },
        {
          "build_id": "a7ba23793697db2e70bfbe6648326398eed71003",
          "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": "0x63a727351f78",
          "line": 9,
          "module_base_address": "0x63a727324000",
          "path": "/home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
          "relative_address": "0x000000000002df78",
          "sp": "0x7ffc91dce800"
        },
        {
          "build_id": "a7ba23793697db2e70bfbe6648326398eed71003",
          "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": "0x63a72735283b",
          "line": 172,
          "module_base_address": "0x63a727324000",
          "path": "/home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
          "relative_address": "0x000000000002e83b",
          "sp": "0x7ffc91dcf000"
        },
        {
          "build_id": "a7ba23793697db2e70bfbe6648326398eed71003",
          "build_id_type": "GNU",
          "file_type": "ELF",
          "function": "main",
          "ip": "0x63a727353cd9",
          "module_base_address": "0x63a727324000",
          "path": "/home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
          "relative_address": "0x000000000002fcd9",
          "sp": "0x7ffc91dcf010"
        },
        {
          "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": "0x727c09d0ed90",
          "line": 58,
          "module_base_address": "0x727c09ce5000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x0000000000029d90",
          "sp": "0x7ffc91dcf110"
        },
        {
          "build_id": "4f7b0c955c3d81d7cac1501a2498b69d1d82bfe7",
          "build_id_type": "GNU",
          "column": 5,
          "file": "./csu/../csu/libc-start.c",
          "file_type": "ELF",
          "function": "__libc_start_main_impl",
          "ip": "0x727c09d0ee40",
          "line": 379,
          "module_base_address": "0x727c09ce5000",
          "path": "/usr/lib/x86_64-linux-gnu/libc.so.6",
          "relative_address": "0x0000000000029e40",
          "sp": "0x7ffc91dcf1b0",
          "symbol_address": "0x727c09d0edc0"
        },
        {
          "build_id": "a7ba23793697db2e70bfbe6648326398eed71003",
          "build_id_type": "GNU",
          "file_type": "ELF",
          "function": "_start",
          "ip": "0x63a727350b25",
          "module_base_address": "0x63a727324000",
          "path": "/home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
          "relative_address": "0x000000000002cb25",
          "sp": "0x7ffc91dcf200"
        }
      ],
      "incomplete": false
    },
    "thread_name": "crashtracker_bi"
  },
  "experimental": {},
  "files": {
    "/proc/self/maps": [
      "63a727324000-63a727350000 r--p 00000000 103:03 19137659                  /home/bits/go/src/github.com/DataDog/libdatadog/target/release/crashtracker_bin_test",
...
      "7ffc91dd6000-7ffc91dda000 r--p 00000000 00:00 0                          [vvar]",
      "7ffc91dda000-7ffc91ddc000 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": 3004337,
    "tid": 3004337
  },
  "sig_info": {
    "si_code": -6,
    "si_code_human_readable": "SI_TKILL",
    "si_signo": 6,
    "si_signo_human_readable": "SIGABRT"
  },
  "timestamp": "2026-07-27 15:40:47.932376685 UTC",
  "ucontext": {
    "arch": "x86_64",
    "raw": ...,
    "registers": {
      "r10": "0x0000000000000008",
...
      "rsp": "0x00007ffc91dce470"
    }
  },
  "uuid": "be0eefee-dd24-4588-b377-a5c144dc1177"
}

gyuheon0h commented Jul 23, 2026

Copy link
Copy Markdown
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@gyuheon0h gyuheon0h changed the title Use GOT patching to retrieve c assert message feat(crashtracking): retrieve c assert message Jul 23, 2026
@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-30 21:47:57

Comparing candidate commit 34cd4ce in PR branch gyuheon0h/PROF-15482-c-assert-msg with baseline commit d224c5d in branch gyuheon0h/got-hook-utils.

Found 5 performance improvements and 5 performance regressions! Performance is the same for 167 metrics, 10 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:alloc_free/sampled_system_fast_path/4096

  • 🟩 execution_time [-12.504ns; -12.448ns] or [-13.763%; -13.702%]

scenario:datadog_sample_span/multiple_rules_last_match/wall_time

  • 🟥 execution_time [+14.472ns; +14.602ns] or [+7.331%; +7.397%]

scenario:ddsketch_encode/into_pb/clustered_near_zero

  • 🟥 execution_time [+6.337ns; +6.947ns] or [+18.399%; +20.171%]

scenario:ddsketch_encode/into_pb/collapsing

  • 🟥 execution_time [+5.741ns; +6.730ns] or [+15.085%; +17.684%]

scenario:ddsketch_encode/into_pb/large_values

  • 🟥 execution_time [+5.768ns; +6.410ns] or [+16.396%; +18.224%]

scenario:ddsketch_encode/into_pb/mixed

  • 🟥 execution_time [+6.075ns; +6.912ns] or [+16.953%; +19.289%]

scenario:glob_matcher/unicode_pattern_ascii_subject/wall_time

  • 🟩 execution_time [-4.673ns; -4.597ns] or [-4.940%; -4.859%]

scenario:glob_matcher/unicode_pattern_wildcard_match/wall_time

  • 🟩 execution_time [-8.278ns; -8.200ns] or [-6.215%; -6.157%]

scenario:trace_buffer/4_senders/no_delay

  • 🟩 execution_time [-264.729µs; -237.667µs] or [-10.603%; -9.519%]
  • 🟩 throughput [+153502.605op/s; +172278.653op/s] or [+10.642%; +11.943%]

Candidate

Omitted due to size.

Baseline

Omitted due to size.

@datadog-datadog-prod-us1-2

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

Copy link
Copy Markdown

Pipelines

Unblock PR with BitsAI

⚠️ Warnings

🚦 23 Pipeline jobs failed

Coverage | coverage   View in Datadog   GitHub Actions

🔧 Fix in code. This looks caused by changes in this PR. Failed to load manifest for dependency 'libdd-got-hook'. Error: No such file or directory at /home/runner/work/libdatadog/libdatadog/libdd-got-hook/Cargo.toml

DataDog/apm-reliability/libdatadog | benchmarks 1/2   View in Datadog   GitLab

Lint | Valid LICENSE-3rdparty.csv   View in Datadog   GitHub Actions

🔧 Fix in code. This looks caused by changes in this PR. Failed to load manifest for dependency 'libdd-got-hook' due to missing file: /home/runner/work/libdatadog/libdatadog/libdd-got-hook/Cargo.toml.

View all 23 failed jobs.

📋 Copy prompt for your agent
CI on my pull request is failing. Help me find and fix the root cause of each failing job below — they were flagged as caused by changes in this PR, so focus on the diff. For each job, explain the failure and propose a fix.

Branch: gyuheon0h/PROF-15482-c-assert-msg

Coverage | coverage
Commit: 3cf6644623a49778776a759f1a7a36741d93caab
Error (code / build):
Failed to load manifest for dependency 'libdd-got-hook'. Error: No such file or directory at /home/runner/work/libdatadog/libdatadog/libdd-got-hook/Cargo.toml
CI job: https://github.com/DataDog/libdatadog/actions/runs/30657801753/job/91246432657

Lint | Valid LICENSE-3rdparty.csv
Commit: 3cf6644623a49778776a759f1a7a36741d93caab
Error (code / build):
Failed to load manifest for dependency 'libdd-got-hook' due to missing file: /home/runner/work/libdatadog/libdatadog/libdd-got-hook/Cargo.toml.
CI job: https://github.com/DataDog/libdatadog/actions/runs/30657802548/job/91246665288

Plus 15 more failing jobs not shown here.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 3cf6644 | 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 2 times, most recently 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 87.33 MB 87.46 MB +.15% (+138.64 KB) 🔍
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 8.01 MB 8.01 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 98.59 MB 98.71 MB +.11% (+115.85 KB) 🔍
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.78 MB 10.78 MB +.02% (+2.98 KB) 🔍
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 26.08 MB 26.08 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 89.60 KB 89.60 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 188.23 MB 188.23 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 980.23 MB 980.23 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.48 MB 8.48 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 89.60 KB 89.60 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 25.08 MB 25.08 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 49.90 MB 49.90 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 22.65 MB 22.65 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 91.00 KB 91.00 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 192.71 MB 192.72 MB +0% (+8.00 KB) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 971.14 MB 971.14 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.55 MB 6.55 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 91.00 KB 91.00 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 26.94 MB 26.94 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 47.50 MB 47.50 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 77.82 MB 77.96 MB +.18% (+150.33 KB) 🔍
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.93 MB 8.94 MB +.13% (+12.00 KB) 🔍
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 93.38 MB 93.53 MB +.15% (+151.59 KB) 🔍
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.87 MB 10.88 MB +.12% (+14.18 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".

Comment thread libdd-crashtracker/src/collector/got_hook.rs Outdated
Comment thread libdd-crashtracker/src/collector/api.rs Outdated
Comment thread libdd-crashtracker/src/collector/got_hook.rs Outdated
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch 2 times, most recently from 217836f to b3f0cf7 Compare July 27, 2026 15:13
@yannham

yannham commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Have yet to look at it, but as a preamble, do you think there's some way to reuse or share the code from libdd-profiling-heap-gotter? It seems some type definitions at least, and probably some functions as well are very similar, if not the same.

@gyuheon0h

Copy link
Copy Markdown
Contributor Author

Have yet to look at it, but as a preamble, do you think there's some way to reuse or share the code from libdd-profiling-heap-gotter? It seems some type definitions at least, and probably some functions as well are very similar, if not the same.

@yannham Yeah. Maybe I shouldn't have opened this yet.

@gyuheon0h
gyuheon0h marked this pull request as draft July 27, 2026 15:52
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch from b8a35c0 to 0af85cb Compare July 27, 2026 15:54
@gyuheon0h
gyuheon0h changed the base branch from main to graphite-base/2268 July 27, 2026 19:13
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch from 0af85cb to 4b6482a Compare July 27, 2026 19:14
@gyuheon0h
gyuheon0h changed the base branch from graphite-base/2268 to gyuheon0h/extract-got-hook-crate July 27, 2026 19:14
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch 3 times, most recently from c55499a to 2dd85ed Compare July 27, 2026 19:36
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/extract-got-hook-crate branch from 822405c to 6ab7768 Compare July 27, 2026 20:01
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/got-hook-utils branch from 4618f83 to 8713e2e Compare July 29, 2026 18:28
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch 2 times, most recently from 0624b47 to a72626c Compare July 29, 2026 19:01
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/got-hook-utils branch from 8713e2e to 0f700c2 Compare July 29, 2026 19:01
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch from a72626c to fe9884f Compare July 29, 2026 19:22
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/got-hook-utils branch from 0f700c2 to 934d93c Compare July 29, 2026 19:22
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch 2 times, most recently from b5959b0 to 48971da Compare July 30, 2026 16:39
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/got-hook-utils branch 2 times, most recently from 5e08f80 to e2110f9 Compare July 30, 2026 17:38
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch from 48971da to 4156403 Compare July 30, 2026 17:38
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/got-hook-utils branch from e2110f9 to cad573a Compare July 30, 2026 17:50
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch 2 times, most recently from d24e571 to 6dbad5d Compare July 30, 2026 18:36
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/got-hook-utils branch from cad573a to 6264ccb Compare July 30, 2026 18:36
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch from 6dbad5d to a26fde9 Compare July 30, 2026 18:55
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/got-hook-utils branch from 6264ccb to d224c5d Compare July 30, 2026 18:58
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch 2 times, most recently from 0054745 to 34cd4ce Compare July 30, 2026 21:01
@gyuheon0h
gyuheon0h marked this pull request as ready for review July 30, 2026 21:01
@gyuheon0h
gyuheon0h requested review from a team as code owners July 30, 2026 21:01

@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: 34cd4cebfb

ℹ️ 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".

Comment on lines +330 to +333
let message_ptr = if message_ptr.is_null() {
super::assert_interceptor::take_assert_message_ptr()
} else {
message_ptr

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 Prefer captured assert messages over stale panic messages

If the process has a Rust panic that is caught after crashtracker initialization, the panic hook leaves PANIC_MESSAGE non-null until the next signal; when a later C assert() aborts, hook_assert_fail has already stored the assertion details, but this branch keeps the stale panic text and never reads the assert message, so the crash report describes the old panic instead of the actual assertion failure. Prefer the assert message for SIGABRT/assert-hook crashes or clear stale panic state before ignoring the new message.

AGENTS.md reference: AGENTS.md:L70-L73

Useful? React with 👍 / 👎.

Comment on lines +95 to +96
let message = format_assert_message(assertion_str, file_str, line, function_str);
store_assert_message(message);

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 Avoid allocator re-entry before aborting asserts

When the intercepted assertion fires from allocator-adjacent code, such as a libc/malloc assertion after heap corruption or while the asserting thread holds an allocator lock, these calls allocate a Rust String/Box before tail-calling the real __assert_fail. That can re-enter or block on the allocator before libc gets to abort, so the process can hang and emit no crash report; capture raw pointers or a fixed-size buffer here and defer formatting until the forked collector runs.

AGENTS.md reference: AGENTS.md:L70-L75

Useful? React with 👍 / 👎.

Comment on lines +122 to +125
libdd_got_hook::hook_symbol(
c"__assert_fail",
hook_assert_fail as *const () as usize,
&mut orig_addr,

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 Keep hooked code valid after unloading the FFI library

In embedders that load libdatadog as the supported .so/FFI library and later dlclose it during extension unload or reload, this permanent GOT patch leaves other modules' __assert_fail slots pointing at hook_assert_fail inside the unloaded image. A subsequent C assert() in any patched module will jump to unmapped/stale code instead of libc, so the hook needs an unpatch/disable-on-unload strategy or the library must be made non-unloadable before patching external GOTs.

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

Useful? React with 👍 / 👎.

@gyuheon0h
gyuheon0h marked this pull request as draft July 30, 2026 21:13
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/got-hook-utils branch from d224c5d to a752f7f Compare July 31, 2026 17:45
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15482-c-assert-msg branch 2 times, most recently from 9829ca0 to 86a6558 Compare July 31, 2026 17:50
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/got-hook-utils branch from a752f7f to 5e2abd9 Compare July 31, 2026 17:50
Hook __assert_fail via GOT patching (using libdd-got-hook) during
crashtracker init. When a C assert() fails, the hook captures the
assertion expression, file, line, and function name before the
process aborts via SIGABRT. The signal handler includes this message
in the crash report.

Only supported on 64-bit Linux; no-op on other platforms.
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/got-hook-utils branch from 5e2abd9 to 788f2de Compare July 31, 2026 19:06
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.

2 participants