Skip to content

feat(crashtracking)!: API to unpatch crashtracker GOT patches - #2492

Draft
gyuheon0h wants to merge 1 commit into
gyuheon0h/got-patch-sigactionfrom
gyuheon0h/PROF-15940-unpatch-crashtracker-GOT-api
Draft

feat(crashtracking)!: API to unpatch crashtracker GOT patches#2492
gyuheon0h wants to merge 1 commit into
gyuheon0h/got-patch-sigactionfrom
gyuheon0h/PROF-15940-unpatch-crashtracker-GOT-api

Conversation

@gyuheon0h

@gyuheon0h gyuheon0h commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Provides an API to unpatch the two symbols that crashtracker patches -- assert_fail and sigaction.

Motivation

Some tracers unload extensions. Unloading libdatadog after its already updated the GOT entries means that symbols now point to now-unmapped areas. We should provide an API for users to call before unloading.

Additional Notes

Anything else we should know when reviewing?

How to test the change?

Describe here in detail how the change can be validated.

@gyuheon0h gyuheon0h changed the title API to unpatch crashtracker GOT patches feat(crashtracking): API to unpatch crashtracker GOT patches Sep 9, 2026

gyuheon0h commented Sep 9, 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 feat(crashtracking): API to unpatch crashtracker GOT patches feat(crashtracking)!: API to unpatch crashtracker GOT patches Sep 9, 2026
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

📚 Documentation Check Results

⚠️ 1113 documentation warning(s) found

📦 libdd-crashtracker - 1113 warning(s)


Updated: 2026-09-11 18:31:44 UTC | Commit: 899fd0d | missing-docs job results

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🔒 Cargo Deny Results

No issues found!

📦 libdd-crashtracker - ✅ No issues


Updated: 2026-09-11 18:30:49 UTC | Commit: 899fd0d | dependency-check job results

@datadog-prod-us1-3

datadog-prod-us1-3 Bot commented Sep 9, 2026

Copy link
Copy Markdown

Tests

All CI checks and tests passed.

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 17.50%
Overall Coverage: 77.77% (-0.02%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: e906f40 | Docs | View more details | Give us feedback!

@pr-commenter

pr-commenter Bot commented Sep 9, 2026

Copy link
Copy Markdown

Benchmarks

Comparison

Benchmark execution time: 2026-09-11 18:41:13

Comparing candidate commit e906f40 in PR branch gyuheon0h/PROF-15940-unpatch-crashtracker-GOT-api with baseline commit 3dff449 in branch gyuheon0h/got-patch-sigaction.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 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 ----------------------------------'

Candidate

Candidate benchmark details

Group 1

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz e906f40 1789151263 gyuheon0h/PROF-15940-unpatch-crashtracker-GOT-api
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 6.299ms 6.460ms ± 0.035ms 6.462ms ± 0.017ms 6.481ms 6.502ms 6.519ms 6.529ms 1.05% -1.722 5.022 0.54% 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 [6.455ms; 6.464ms] or [-0.074%; +0.074%] None None None

Baseline

Baseline benchmark details

Group 1

cpu_model git_commit_sha git_commit_date git_branch
Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz 3dff449 1789151263 gyuheon0h/got-patch-sigaction
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 6.286ms 6.372ms ± 0.033ms 6.370ms ± 0.012ms 6.384ms 6.414ms 6.455ms 6.644ms 4.30% 2.840 22.726 0.51% 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 [6.367ms; 6.377ms] or [-0.071%; +0.071%] None None None

@dd-octo-sts

dd-octo-sts Bot commented Sep 9, 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.so 9.02 MB 9.02 MB +0% (+112 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 96.01 MB 96.02 MB +0% (+9.82 KB) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 12.19 MB 12.19 MB +.01% (+1.50 KB) 🔍
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 107.42 MB 107.43 MB +0% (+9.42 KB) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 29.04 MB 29.04 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 96.08 KB 96.08 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 191.77 MB 191.77 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 818.18 MB 818.18 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 9.69 MB 9.69 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 96.08 KB 96.08 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 27.51 MB 27.51 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 55.57 MB 55.57 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 25.41 MB 25.41 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 97.58 KB 97.58 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 197.08 MB 197.08 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 800.48 MB 800.48 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 7.51 MB 7.51 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 97.58 KB 97.58 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 29.63 MB 29.63 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 52.55 MB 52.55 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 85.97 MB 85.98 MB +0% (+8.10 KB) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 10.03 MB 10.04 MB +.03% (+4.09 KB) 🔍
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 101.85 MB 101.86 MB +0% (+8.00 KB) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 12.25 MB 12.25 MB +0% (+1.20 KB) 👌

@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15940-unpatch-crashtracker-GOT-api branch from bc7c43c to 9e0b34b Compare September 9, 2026 14:41
@gyuheon0h
gyuheon0h marked this pull request as ready for review September 9, 2026 14:45
@gyuheon0h
gyuheon0h requested review from a team as code owners September 9, 2026 14:45
@gyuheon0h
gyuheon0h marked this pull request as draft September 9, 2026 14:51

@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: 9e0b34bd99

ℹ️ 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/lib.rs Outdated
target_os = "linux",
target_pointer_width = "64"
))]
pub use collector::uninstall_hooks;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Export the uninstall operation through the C FFI

The new function is only a Rust API, so the SDKs that load the generated libdatadog shared library cannot call it before dlclose. The existing initialization path is exposed as ddog_crasht_init through libdd-crashtracker-ffi, and libdd-profiling-ffi only re-exports that FFI crate; a repository-wide search finds no corresponding #[no_mangle] extern "C" uninstall function. Add the FFI wrapper so the intended unloading tracers can actually use this feature.

AGENTS.md reference: AGENTS.md:L3-L3

Useful? React with 👍 / 👎.

Comment thread libdd-crashtracker/src/collector/api.rs Outdated
Comment on lines +112 to +113
super::assert_interceptor::uninstall_assert_hook();
super::sigaction_interceptor::uninstall_sigaction_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.

P1 Badge Restore every callback installed by init before unloading

When init succeeds, it also registers handle_posix_sigaction as the process signal handler and installs a Rust panic-hook closure (api.rs lines 87-88), but this teardown only removes the two GOT hooks. After the containing shared library is unloaded, those process-global callbacks still point into its unmapped code, so a monitored signal or Rust panic jumps to a dangling address despite the caller having invoked the documented pre-unload API. The teardown needs to restore the previous signal and panic handlers as well, or it must not be presented as the operation to call before unloading.

Useful? React with 👍 / 👎.

// SAFETY: all libraries patched at hook time are still loaded
// (the crashtracker itself is live, so the process hasn't exited).
// The caller must ensure sigaction is not called concurrently.
unsafe { libdd_gotter::unhook_symbol(&result, hook_sigaction as *const () as usize) };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Propagate incomplete unhooking instead of discarding it

If mprotect fails or a slot no longer contains this hook—for example because another interposer was installed later—unhook_symbol reports fewer restored entries, but this call discards that result and then clears both the saved HookResult and ORIG_SIGACTION_FN. The public API consequently reports success and cannot retry even though GOT slots or a later hook's saved original may still reference libdatadog, making the subsequent unload unsafe. Return a structured error and retain enough state to retry or tell the caller not to unload; the identical assert-hook call has the same issue.

AGENTS.md reference: AGENTS.md:L72-L73

Useful? React with 👍 / 👎.

Comment on lines +252 to +253
// SAFETY: all libraries patched at hook time are still loaded.
unsafe { libdd_gotter::unhook_symbol(&result, hook_assert_fail as *const () as usize) };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Validate saved GOT slots before dereferencing them

If any DSO whose GOT was patched during init is dlclosed before this API runs, the saved raw slot addresses no longer satisfy unhook_symbol's requirement that every address remain mapped. The public safe API neither documents nor enforces that lifetime; worse, if another mapping reuses an old address, make_writable can succeed and the CAS can modify unrelated memory. This is especially relevant to an API intended for runtimes that unload extensions, so the implementation must associate slots with loaded-object identity and skip stale/reused mappings, or require and expose the lifetime precondition as an unsafe contract.

Useful? React with 👍 / 👎.

@gyuheon0h
gyuheon0h changed the base branch from gyuheon0h/unpatch-gotter to graphite-base/2492 September 9, 2026 18:56
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15940-unpatch-crashtracker-GOT-api branch from 9e0b34b to 62f5c05 Compare September 9, 2026 18:57
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15940-unpatch-crashtracker-GOT-api branch from 62f5c05 to 42bfd62 Compare September 9, 2026 19:01
@gyuheon0h
gyuheon0h changed the base branch from graphite-base/2492 to gyuheon0h/got-patch-sigaction September 9, 2026 19:29
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/got-patch-sigaction branch from 4c9f499 to b63b056 Compare September 11, 2026 16:57
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15940-unpatch-crashtracker-GOT-api branch 2 times, most recently from 0b72ac4 to c3a07e9 Compare September 11, 2026 17:54
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/got-patch-sigaction branch from b63b056 to 16ba2cd Compare September 11, 2026 17:54
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15940-unpatch-crashtracker-GOT-api branch 2 times, most recently from bdc3300 to 9b1f7c1 Compare September 11, 2026 18:24
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/got-patch-sigaction branch from 16ba2cd to 3dff449 Compare September 11, 2026 18:29
@gyuheon0h
gyuheon0h force-pushed the gyuheon0h/PROF-15940-unpatch-crashtracker-GOT-api branch from 9b1f7c1 to e906f40 Compare September 11, 2026 18:29
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