-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 error handling for COM initialization failures during thread startup #72353
Conversation
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
|
||
_initialApartmentState = state; | ||
return true; | ||
retState = _initialApartmentState; |
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.
(this != CurrentThread)
path needs to have the same error handling and throw InvalidOperationException as the (this == CurrentThread)
path.
@@ -367,9 +368,13 @@ private void StartCore() | |||
|
|||
if (GetThreadStateBit(ThreadState.Unstarted)) | |||
{ | |||
// Lack of memory is the only expected reason for thread creation failure |
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.
This was incorrect assumption. COM initialization can fail with PlatformNotSupportedException on Nano server.
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.
I'm not an expert in the area, but functionally looks good and the tests are passing. Thanks for the comments too
// Lack of memory is the only expected reason for thread creation failure | ||
throw new ThreadStartException(new OutOfMemoryException()); | ||
Exception? startException = _startException; | ||
startException = null; |
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.
Is this correct?
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.
I think this should be _startException = null;
Fixes #72352