[release/6.0] Change macOS activatin injection failure handling #63393
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #59045 to release/6.0
The pthread_kill can fail with ENOTSUP on macOS when the target thread
is a dispatch queue thread. Instead of aborting the process, it is
better to fail to inject the activation and rely on return address
hijacking and other means of syncing with GC.
Customer Impact
Without this change, .NET 6 apps that execute code on dispatch queue threads were reported to abort during GC thread suspension by the Excel team and another 3rd party customer. While Excel team was able to work around the problem by not executing managed code on dispatch queue threads, the other customer was unable to do that due to their heavy usage of these threads.
Testing
coreclr and libraries tests locally. The change has been in main branch for about three months without issues.
Risk
Low, the change only prevents the process from dying immediately when
pthread_killis not supported for the target thread.