feat(crashtracking): retrieve c assert message for linux when __assert_fail is dynamically loaded - #2268
Conversation
|
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.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
f3e6979 to
6e7f47d
Compare
BenchmarksComparisonBenchmark execution time: 2026-07-27 21:16:39 Comparing candidate commit 6fca2eb in PR branch Found 4 performance improvements and 0 performance regressions! Performance is the same for 173 metrics, 10 unstable metrics.
|
|
13ad896 to
28b571f
Compare
__assert_fail is dynamically loaded
__assert_fail is dynamically loaded__assert_fail is dynamically loaded
6b2f473 to
7568fed
Compare
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
There was a problem hiding this comment.
💡 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".
217836f to
b3f0cf7
Compare
|
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. |
b8a35c0 to
0af85cb
Compare
0af85cb to
4b6482a
Compare
📚 Documentation Check Results📦
|
🔒 Cargo Deny Results📦
|
44f1bd5 to
c55499a
Compare
c55499a to
2dd85ed
Compare
822405c to
6ab7768
Compare
2dd85ed to
854221b
Compare
6ab7768 to
285cdd3
Compare
854221b to
6e261bd
Compare
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.
6e261bd to
6fca2eb
Compare

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_failso calls are redirected to our hook function. My initial thought was to useLD_PRELOADbut this approach works no matter the load order.I was inspired by
libdd-profiling-heap-gotterwhich does something similar to interceptmalloc/freefor heap profiling.During
crashtracker::init(),install_assert_hook()PT_DYNAMICsegment to locate its relocation tablesWhen a C
assert()fails:The hook captures the assertion expression, file name, line no, func name, and stores it through an atomic pointer:
__assert_fail()implementation.abort(), which raises SIGABRT.Unfortunately, this doesn't work everywhere
__assert_failhas no GOT entry to patch. The hook installs silently as a 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?