Commit fdaa4a3
[clr-interp] Skip RSLock leak assert for DbgTransportTarget on Unix (#127754)
## Description
The static `g_DbgTransportTarget` instance is destroyed after the host
process's `main()` returns. On Unix (desktop interpreter) the dynamic
loader does not invoke `DbgDllMain(DLL_PROCESS_DETACH)` for
`mscordbi.dylib`, so `DbgTransportTarget::Shutdown()` may never run and
the embedded `RSLock m_sLock` is left in its initialized state. In debug
builds the `RSLock` destructor asserts that the lock was `Destroy()`'d
before destruction, so the host process aborts.
## Implementation
The shutdown path can't be made reliable on Unix without changes outside
`mscordbi`, so the fix opts the lock out of the destructor assert
instead of trying to release it:
- Add a new `RSLock` attribute `cLockAllowLeak`
(`src/coreclr/debug/di/rspriv.h`) for static-lifetime locks whose owning
shutdown path is not guaranteed to run.
- Update `~RSLock()` (`src/coreclr/debug/di/rspriv.inl`) so the existing
`CONSISTENCY_CHECK_MSGF` leak assert is bypassed when `cLockAllowLeak`
is set; behavior for all other locks is unchanged.
- Initialize `DbgTransportTarget::m_sLock` with `cLockFlat |
cLockAllowLeak` (`src/coreclr/debug/di/dbgtransportmanager.cpp`) so the
static instance no longer trips the assert when destructed after
`main()` returns.
## Test impact
Locally on osx-arm64 `Debugger.Tests --clrinterpreter` the xunit fail
count drops from 230 to 65:
- `Inspection.BasicInspection`, `Inspection.EnumNames`,
`Inspection.GenericInterfaces`, `Inspection.GenericSharedStatic`,
`Inspection.GenericStatics`, `Inspection.NestedGenerics`,
`Inspection.inspect_SetVars`
- `Stackwalking.ClrMethods`
- `Stepping.setIPTestwithUnvaildPos`, `Stepping.stepin`,
`Stepping.stepover`
- `Async.AsyncStepInto`
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 81b4a53 commit fdaa4a3
3 files changed
Lines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
716 | 716 | | |
717 | 717 | | |
718 | 718 | | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
719 | 723 | | |
720 | 724 | | |
721 | 725 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
504 | 504 | | |
505 | 505 | | |
506 | 506 | | |
507 | | - | |
508 | | - | |
509 | | - | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
| |||
0 commit comments