runtime
runtime copied to clipboard
[MT][browser] `TaskIDFromExternalContextTest` fails, Task has a negative ID
Failing after enabling all MT library tests (https://github.com/dotnet/runtime/pull/91536).
[FAIL] System.Threading.Tasks.Tests.ParallelForTests.TaskIDFromExternalContextTest
Task within Parallel.For must have non-negative Id
Expected: False
Actual: True
at System.Threading.Tasks.Tests.ParallelForTests.<>c.<TaskIDFromExternalContextTest>b__4_1(Int32 i)
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2[[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2[[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Run[RangeWorker](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
at System.Threading.Tasks.Parallel.ForWorker[Object,Int32](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action`1 body)
at System.Threading.Tasks.Tests.ParallelForTests.TaskIDFromExternalContextTest()
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Error Blob
{
"ErrorMessage": "[FAIL] System.Threading.Tasks.Tests.ParallelForTests.TaskIDFromExternalContextTest",
"ErrorPattern": "",
"BuildRetry": false,
"ExcludeConsoleLog": false
}
Build: https://dev.azure.com/dnceng-public/public/_build/results?buildId=523904
Known issue validation
Build: :mag_right: https://dev.azure.com/dnceng-public/public/_build/results?buildId=523904
Error message validated: [FAIL] System.Threading.Tasks.Tests.ParallelForTests.TaskIDFromExternalContextTest
Result validation: :white_check_mark: Known issue matched with the provided build.
Validation performed at: 1/11/2024 6:33:01 PM UTC
Report
| Build | Definition | Test | Pull Request |
|---|---|---|---|
| 533238 | dotnet/runtime | WasmTestOnBrowser-System.Threading.Tasks.Parallel.Tests.WorkItemExecution | dotnet/runtime#96841 |
| 523904 | dotnet/runtime | WasmTestOnBrowser-System.Threading.Tasks.Parallel.Tests.WorkItemExecution | dotnet/runtime#96618 |
Summary
| 24-Hour Hit Count | 7-Day Hit Count | 1-Month Count |
|---|---|---|
| 0 | 1 | 2 |
Tagging subscribers to 'arch-wasm': @lewing See info in area-owners.md if you want to be subscribed.
Issue Details
Failing after enabling all MT library tests (https://github.com/dotnet/runtime/pull/91536).
[FAIL] System.Threading.Tasks.Tests.ParallelForTests.TaskIDFromExternalContextTest
Task within Parallel.For must have non-negative Id
Expected: False
Actual: True
at System.Threading.Tasks.Tests.ParallelForTests.<>c.<TaskIDFromExternalContextTest>b__4_1(Int32 i)
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2[[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2[[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
at System.Threading.Tasks.TaskReplicator.Run[RangeWorker](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
at System.Threading.Tasks.Parallel.ForWorker[Object,Int32](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action`1 body)
at System.Threading.Tasks.Tests.ParallelForTests.TaskIDFromExternalContextTest()
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
| Author: | ilonatommy |
|---|---|
| Assignees: | - |
| Labels: |
|
| Milestone: | - |
@lambdageek said "maybe we didn't implement Volatile.Read for MT? or maybe the jiterp doesn't implement it?"
cc @kg
I'm probably wrong about that 😄
Volatile.Read turns into an indirect load from a volatile local. which turns into interp_emit_memory_barrier which turns into mono_memory_barrier () at runtime.
and that is... __sync_synchronize () which is a compiler intrinsic. According to https://github.com/WebAssembly/tool-conventions/issues/59 I guess that turns into an atomic.fence instruction
I don't remember ever implementing atomics in the jiterpreter period
yea it looks like MINT_MONO_MEMORY_BARRIER is just an unsupported opcode for the jiterp. so that doesn't enter into it
This is how to run the test
dotnet build /p:TargetOS=browser /p:TargetArchitecture=wasm /p:Configuration=Debug /t:Test /p:Scenario=WasmTestOnBrowser /p:MonoWasmBuildVariant=multithread /p:WasmEnableThreads=true src\libraries\System.Threading.Tasks\tests\System.Threading.Tasks.Tests.csproj /p:WasmTestAppArgs="-method System.Threading.Tasks.Tests.ParallelForTests.TaskIDFromExternalContextTest"
It doesn't reproduce for me when I run it few times. Perhaps it needs to fail as part of the whole suite.
Another Log
[16:58:55] info: [2024-01-11T16:58:55.670Z] [FAIL] System.Threading.Tasks.Tests.ParallelForTests.TaskIDFromExternalContextTest
[16:58:55] info: Task within Parallel.For must have non-negative Id
[16:58:55] info: at System.Threading.Tasks.Tests.ParallelForTests.<>c.<TaskIDFromExternalContextTest>b__20_1(Int32 i)
[16:58:55] info: at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2[[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
[16:58:55] info: --- End of stack trace from previous location ---
[16:58:55] info: at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`2[[System.Object, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Int32, System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<ForWorker>b__1(RangeWorker& currentWorker, Int64 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
[16:58:55] info: at System.Threading.Tasks.TaskReplicator.Run[RangeWorker](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
[16:58:55] info: at System.Threading.Tasks.Parallel.ForWorker[Object,Int32](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
[16:58:55] info: at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action`1 body)
[16:58:55] info: at System.Threading.Tasks.Tests.ParallelForTests.TaskIDFromExternalContextTest()
[16:58:55] info: at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[16:58:55] info: at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)