-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix fail-fast due to unlocked FreeProcessData call #12599
Conversation
4c8603d
to
bc01b34
Compare
|
||
// FreeProcessData() above requires the console to be locked. | ||
UnlockConsole(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For reviewers, here's the original code again:
terminal/src/server/IoDispatchers.cpp
Lines 441 to 454 in 40e3dea
Error: | |
FAIL_FAST_IF(NT_SUCCESS(Status)); | |
if (ProcessData != nullptr) | |
{ | |
CommandHistory::s_Free((HANDLE)ProcessData); | |
gci.ProcessHandleList.FreeProcessData(ProcessData); | |
} | |
UnlockConsole(); | |
pReceiveMsg->SetReplyStatus(Status); | |
return pReceiveMsg; |
This is the fail-fast:
terminal/src/server/ProcessList.cpp
Lines 86 to 88 in d0d42c4
void ConsoleProcessList::FreeProcessData(_In_ ConsoleProcessHandle* const pProcessData) | |
{ | |
FAIL_FAST_IF(!(ServiceLocator::LocateGlobals().getConsoleInformation().IsConsoleLocked())); |
(SetReplyStatus
is just a primitive setter and can be called under the console lock AFAICS.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI the stack trace is:
0:000> kc
# Call Site
00 KERNELBASE!RaiseFailFastException
01 conhost!wil::details::WilDynamicLoadRaiseFailFastException
02 conhost!wil::details::WilRaiseFailFastException
03 conhost!wil::details::WilFailFast
04 conhost!wil::details::ReportFailure_NoReturn<3>
05 conhost!wil::details::ReportFailure_Base<3,0>
06 conhost!wil::details::ReportFailure_Hr<3>
07 conhost!wil::details::in1diag3::_FailFast_Unexpected
08 conhost!wil::details::in1diag3::FailFast_If
09 conhost!ConsoleProcessList::FreeProcessData
0a conhost!<lambda_f86d5fd29b665fa3f430c14358e0681a>::operator()
0b conhost!wil::details::lambda_call<<lambda_f86d5fd29b665fa3f430c14358e0681a> >::reset
0c conhost!wil::details::lambda_call<<lambda_f86d5fd29b665fa3f430c14358e0681a> >::~lambda_call<<lambda_f86d5fd29b665fa3f430c14358e0681a> >
0d conhost!IoDispatchers::ConsoleHandleConnectionRequest
0e conhost!IoSorter::ServiceIoOperation
0f conhost!ConsoleIoThread
10 kernel32!BaseThreadInitThunk
11 ntdll!RtlUserThreadStart
Hello @lhecker! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
I think this might not need to go to 1.12 stable as it had a conflict when I cherry-picked that seemed to show 1.12 didn't have the original bug. |
UGH probably needs an OS side fix. |
Pulled to OS. Not in 1.12, untagging. |
2b202ce introduced a bug, where FreeProcessData was called without the console lock being held. The previous code can be found in 40e3dea, on line 441-454. ## PR Checklist * [x] Closes MSFT:21372705 * [x] I work here * [x] Tests added/passed ## Validation Steps Performed None, as this fix is purely theoretic, but it matches the stack trace and 40e3dea clearly wasn't correctly ported to strict C++ either. (cherry picked from commit 79a08ec)
2b202ce introduced a bug, where FreeProcessData was called without the console lock being held. The previous code can be found in 40e3dea, on line 441-454. ## PR Checklist * [x] Closes MSFT:21372705 * [x] I work here * [x] Tests added/passed ## Validation Steps Performed None, as this fix is purely theoretic, but it matches the stack trace and 40e3dea clearly wasn't correctly ported to strict C++ either.
2b202ce introduced a bug, where FreeProcessData was called without the console
lock being held. The previous code can be found in 40e3dea, on line 441-454.
PR Checklist
Validation Steps Performed
None, as this fix is purely theoretic, but it matches the stack trace
and 40e3dea clearly wasn't correctly ported to strict C++ either.