Commit c43abbb
Simplify dataflow synchronization (#7853)
## Summary of changes
This PR simplifies the lifecycle and usage of iast::Dataflow within the
.NET tracer by removing unnecessary synchronization complexity and
consolidating initialization logic. After validating that the profiler’s
lifecycle guarantees make the race condition targeted in
[#7838](#7838)
impossible, the extra locking and state checks introduced there were
identified as unnecessary. This PR therefore removes them and replaces
them with a clearer, more maintainable initialization model.
The end result is the same runtime behavior, but with cleaner, more
predictable code paths.
## Reason for change
During investigation of the suspected race in Dataflow, we discovered:
_dataflow is created before any IAST-related callbacks can run.
_dataflow is destroyed only during CorProfiler::Shutdown, after all
runtime callbacks have stopped.
Therefore, there is no window where runtime threads can access a
partially-initialized or null Dataflow instance.
Because the profiler’s lifecycle already prevents the problematic
interleavings, the additional locking and defensive checks from #7838
were redundant. They increased complexity without improving correctness.
This PR cleans that up.
## Implementation details
What this PR does
1. Consolidates Dataflow initialization logic
Dataflow::LoadAspects becomes the single, authoritative entry point for
initialization. No scattered flags, no duplicated checks.
2. Removes unnecessary locking around initialization
Since lifecycle guarantees prevent concurrent initialization, the
critical-section guarding and initialization state added in #7838 are
removed.
3. Simplifies callback paths
Profiler callbacks (ModuleLoaded, ModuleUnloaded, IAST instrumentation
setup, etc.) now:
Assume _dataflow exists.
Only guard the internal data structures that are actually accessed
concurrently.
Remove early-return branches and over-defensive locking patterns.
4. Cleans up dead code and unused members
Any state variables, flags, or locking constructs made obsolete by the
simplified lifecycle are removed, shrinking the Dataflow class
footprint.
Result
Same behavioral correctness.
Fewer code paths and edge cases.
Clearer lifecycle contract: Dataflow always exists during the period
where callbacks may use it.
Easier to maintain and reason about for future IAST development.
## Test coverage
Re-ran IAST tests on Windows x86/x64 to confirm no regressions.
Validated profiler lifecycle behavior to ensure _dataflow is always
valid during runtime callbacks.
Confirmed no reappearance of previous intermittent failures.
## Other details
---------
Co-authored-by: Andrew Lock <[email protected]>1 parent 8c4a8c4 commit c43abbb
File tree
3 files changed
+9
-46
lines changed- tracer/src/Datadog.Tracer.Native
- iast
3 files changed
+9
-46
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
255 | 255 | | |
256 | 256 | | |
257 | 257 | | |
258 | | - | |
| 258 | + | |
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| |||
1301 | 1301 | | |
1302 | 1302 | | |
1303 | 1303 | | |
1304 | | - | |
1305 | | - | |
1306 | 1304 | | |
1307 | 1305 | | |
1308 | 1306 | | |
| |||
2072 | 2070 | | |
2073 | 2071 | | |
2074 | 2072 | | |
| 2073 | + | |
2075 | 2074 | | |
2076 | 2075 | | |
2077 | 2076 | | |
2078 | 2077 | | |
| 2078 | + | |
2079 | 2079 | | |
2080 | 2080 | | |
2081 | 2081 | | |
| |||
2090 | 2090 | | |
2091 | 2091 | | |
2092 | 2092 | | |
| 2093 | + | |
2093 | 2094 | | |
2094 | 2095 | | |
2095 | 2096 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
186 | 185 | | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | 186 | | |
191 | 187 | | |
192 | 188 | | |
193 | 189 | | |
194 | | - | |
195 | | - | |
196 | | - | |
| 190 | + | |
197 | 191 | | |
| 192 | + | |
| 193 | + | |
198 | 194 | | |
199 | 195 | | |
200 | 196 | | |
| |||
369 | 365 | | |
370 | 366 | | |
371 | 367 | | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | 368 | | |
378 | 369 | | |
379 | 370 | | |
| |||
388 | 379 | | |
389 | 380 | | |
390 | 381 | | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | 382 | | |
397 | 383 | | |
398 | 384 | | |
399 | 385 | | |
400 | 386 | | |
401 | 387 | | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | 388 | | |
408 | 389 | | |
409 | 390 | | |
| |||
608 | 589 | | |
609 | 590 | | |
610 | 591 | | |
| 592 | + | |
611 | 593 | | |
612 | 594 | | |
613 | 595 | | |
| |||
618 | 600 | | |
619 | 601 | | |
620 | 602 | | |
621 | | - | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
626 | 603 | | |
627 | 604 | | |
628 | 605 | | |
| |||
632 | 609 | | |
633 | 610 | | |
634 | 611 | | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | 612 | | |
641 | 613 | | |
642 | 614 | | |
643 | 615 | | |
644 | 616 | | |
645 | | - | |
646 | | - | |
647 | | - | |
648 | | - | |
649 | | - | |
| 617 | + | |
650 | 618 | | |
651 | 619 | | |
652 | 620 | | |
| |||
783 | 751 | | |
784 | 752 | | |
785 | 753 | | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | 754 | | |
792 | 755 | | |
793 | 756 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | 68 | | |
70 | 69 | | |
71 | 70 | | |
| |||
0 commit comments