Make native span ownership exception-safe - #6128
Conversation
Keep each raw `ddog_TracerSpan` under an ensure-backed owner until `TypedData` or trace chunks consume it. This prevents Ruby non-local exits during meta and metrics conversion or partial batch construction from leaking native spans. Apply fallible exporter configuration before creating the separately owned shared runtime so rejected configuration cannot leak it. Refs: APMSP-3829
|
Thank you for updating Change log entry section 👏 Visited at: 2026-07-30 12:12:06 UTC |
f8b276b to
853a676
Compare
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 853a676 | Docs | Datadog PR Page | Give us feedback! |
BenchmarksBenchmark execution time: 2026-07-30 12:26:03 Comparing candidate commit 853a676 in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 48 metrics, 1 unstable metrics.
|
AI-generated code disclosure: this PR was implemented with substantial AI assistance and manually reviewed and validated.
What does this PR do?
Makes raw native span ownership exception-safe across Ruby non-local exits, TypedData wrapping, batch transfer, warning and hash mutation paths, partial batches, and exporter configuration and runtime setup.
Motivation:
Ruby exceptions and non-local exits can interrupt native ownership transfer and leak or double-release spans unless every transition has an explicit cleanup path. This is the internal safety work tracked by APMSP-3829.
Change log entry
No.
Additional Notes:
How to test the change?
ruby_memchecksuite under Valgrind: 34 examples, 0 failures, with no reported leaks.