-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix invalid continuation caused by exception after inlining in TryRunInline
#115659
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 invalid continuation caused by exception after inlining in TryRunInline
#115659
Conversation
Tagging subscribers to this area: @dotnet/area-system-threading-tasks |
Cc. @stephentoub |
src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/Task.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/Task/TaskRtTests_Core.cs
Outdated
Show resolved
Hide resolved
Thanks! If this is the root cause, it's interesting that folks have only started reporting it recently. As far as I can tell, it's been like this for 15 years. :) You also mentions this "contributes" to the original issue; do you believe this is only part of it? |
…s/Task.cs Co-authored-by: Stephen Toub <stoub@microsoft.com>
I believe this is the only part to the fix, though I can’t say for sure. It’s interesting that reports have only started appearing recently. |
The reproduction test is unreliable. It fails under debug configurations, and I haven’t been able to set conditions for consistently successful runs. Adding more retry attempts could improve reliability, but it would also slow down the CI. @stephentoub Let me know how you want to proceed:
|
Whether or not it fully solves the issue, the fix is small and correct and shouldn't hurt, so let's go ahead and merge it. Thanks. |
Description
When a task was inlined in
TryRunInline
, and if an exception was thrown after inlining, it would callFinish
in the catch block due to an invalidtaskQueued
value, which set the sentinel in the continuation object. Later, this could causeExecuteWithThreadLocal
to invokeFinish
again and try to run the sentinel as a continuation, throwingInvalidCastException
.Contributes to #83520