Skip to content
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

Merged
merged 1 commit into from
Jul 18, 2022

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Jul 18, 2022

Fixes #72352

@jkotas
Copy link
Member Author

jkotas commented Jul 18, 2022

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).


_initialApartmentState = state;
return true;
retState = _initialApartmentState;
Copy link
Member Author

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
Copy link
Member Author

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.

Copy link
Contributor

@tlakollo tlakollo left a 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

@jkotas jkotas merged commit a567d4c into dotnet:main Jul 18, 2022
@jkotas jkotas deleted the issue-72352 branch July 18, 2022 19:44
// Lack of memory is the only expected reason for thread creation failure
throw new ThreadStartException(new OutOfMemoryException());
Exception? startException = _startException;
startException = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this correct?

Copy link
Member

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;

@ghost ghost locked as resolved and limited conversation to collaborators Aug 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

system.threading.thread.tests work item
3 participants