fix(iast): fix crashes at teardown#18534
Conversation
|
Codeowners resolved as |
db9500e to
fb15bbd
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fb15bbd5a0
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
BenchmarksBenchmark execution time: 2026-06-09 13:53:29 Comparing candidate commit 6786517 in PR branch Found 0 performance improvements and 2 performance regressions! Performance is the same for 82 metrics, 0 unstable metrics. scenario:iast_aspects-re_expand_aspect
scenario:iastaspectsospath-ospathbasename_aspect
|
fb15bbd to
7f3241c
Compare
|
This change is marked for backport to 4.8, but it conflicts with that branch. The command used to test backporting was |
|
This change is marked for backport to 4.9, but it conflicts with that branch. The command used to test backporting was |
|
This change is marked for backport to 4.10, but it conflicts with that branch. The command used to test backporting was |
|
This change is marked for backport to 4.11 and it does not conflict with that branch. |
Co-authored-by: Alberto Vara <alberto.vara@datadoghq.com>
856135e
into
main
Description
This PR fixes crashes (caught by Crash Tracking) caused by IAST trying to access freed memories during interpreter shutdown.
is_textsupposedly safely access objects but can only check whether the addresses make sense, it can't know whether objects have been freed.dd-trace-py/ddtrace/appsec/_iast/_taint_tracking/utils/string_utils.h
Lines 50 to 67 in 160d0fb
When uvloop's
run_until_completeunwinds (Py_XDECREFin frames 57 to 61), custom type objects can be freed by the cyclic GC before all of their instances finish cleanup. An instance can still have a positive refcount, its pointer is non-null and aligned,ob_typeis non-null, but the type it points to has been deallocated.There's already a
shutting_downguard inget_tainted_object_map_from_pyobject, butget_tainted_object_mapcallsis_text(obj)before reaching that.dd-trace-py/ddtrace/appsec/_iast/_taint_tracking/context/taint_engine_context.cpp
Lines 140 to 147 in c641709
Example crashing stack