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

[MT][browser] TaskIDFromExternalContextTest fails, Task has a negative ID #91583

Closed
ilonatommy opened this issue Sep 5, 2023 · 7 comments · Fixed by #97505 or #102212
Closed

[MT][browser] TaskIDFromExternalContextTest fails, Task has a negative ID #91583

ilonatommy opened this issue Sep 5, 2023 · 7 comments · Fixed by #97505 or #102212
Assignees
Labels
arch-wasm WebAssembly architecture area-VM-threading-mono Known Build Error Use this to report build issues in the .NET Helix tab
Milestone

Comments

@ilonatommy
Copy link
Member

ilonatommy commented Sep 5, 2023

Failing after enabling all MT library tests (#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: 🔎 https://dev.azure.com/dnceng-public/public/_build/results?buildId=523904
Error message validated: [FAIL] System.Threading.Tasks.Tests.ParallelForTests.TaskIDFromExternalContextTest
Result validation: ✅ Known issue matched with the provided build.
Validation performed at: 1/11/2024 6:33:01 PM UTC

Report

Build Definition Test Pull Request
540124 dotnet/runtime System.Threading.Tasks.Tests.ParallelForTests.TaskIDFromExternalContextTest #97441
536247 dotnet/runtime WasmTestOnBrowser-System.Threading.Tasks.Parallel.Tests.WorkItemExecution #97270
535842 dotnet/runtime WasmTestOnBrowser-System.Threading.Tasks.Parallel.Tests.WorkItemExecution #97270
533238 dotnet/runtime WasmTestOnBrowser-System.Threading.Tasks.Parallel.Tests.WorkItemExecution #96841
523904 dotnet/runtime WasmTestOnBrowser-System.Threading.Tasks.Parallel.Tests.WorkItemExecution #96618

Summary

24-Hour Hit Count 7-Day Hit Count 1-Month Count
1 4 5
@ilonatommy ilonatommy added arch-wasm WebAssembly architecture disabled-test The test is disabled in source code against the issue area-Build-mono area-VM-threading-mono labels Sep 5, 2023
@ghost ghost added the untriaged New issue has not been triaged by the area owner label Sep 5, 2023
@ghost
Copy link

ghost commented Sep 5, 2023

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 (#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:

arch-wasm, disabled-test, area-Build-mono, area-VM-threading-mono

Milestone: -

@lewing lewing modified the milestones: 8.0.0, 9.0.0 Sep 5, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Sep 5, 2023
@pavelsavara
Copy link
Member

image

@lambdageek said "maybe we didn't implement Volatile.Read for MT? or maybe the jiterp doesn't implement it?"

cc @kg

@lambdageek
Copy link
Member

lambdageek commented Nov 6, 2023

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 WebAssembly/tool-conventions#59 I guess that turns into an atomic.fence instruction

@kg
Copy link
Member

kg commented Nov 6, 2023

I don't remember ever implementing atomics in the jiterpreter period

@lambdageek
Copy link
Member

yea it looks like MINT_MONO_MEMORY_BARRIER is just an unsupported opcode for the jiterp. so that doesn't enter into it

@pavelsavara
Copy link
Member

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.

@pavelsavara
Copy link
Member

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)

@pavelsavara pavelsavara added Known Build Error Use this to report build issues in the .NET Helix tab and removed disabled-test The test is disabled in source code against the issue labels Jan 11, 2024
radekdoulik added a commit to radekdoulik/runtime that referenced this issue Jan 25, 2024
@ghost ghost added in-pr There is an active PR which will close this issue when it is merged and removed in-pr There is an active PR which will close this issue when it is merged labels Jan 25, 2024
@lewing lewing assigned radekdoulik and unassigned pavelsavara Jan 25, 2024
@ghost ghost added the in-pr There is an active PR which will close this issue when it is merged label Jan 25, 2024
@ghost ghost removed the in-pr There is an active PR which will close this issue when it is merged label Jan 26, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 25, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
arch-wasm WebAssembly architecture area-VM-threading-mono Known Build Error Use this to report build issues in the .NET Helix tab
Projects
None yet
8 participants