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

[wasm] Incorrect handling of null target in ReleaseJSOwnedObjectByGCHandle #107486

Open
kg opened this issue Sep 6, 2024 · 4 comments
Open

[wasm] Incorrect handling of null target in ReleaseJSOwnedObjectByGCHandle #107486

kg opened this issue Sep 6, 2024 · 4 comments
Assignees
Labels
arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm
Milestone

Comments

@kg
Copy link
Contributor

kg commented Sep 6, 2024

Log

[19:47:52] info: [FAIL] System.Runtime.InteropServices.JavaScript.Tests.JSImportTest.JsImportArraySegmentOfInt32
[19:47:52] info: System.NullReferenceException : Object reference not set to an instance of an object.
[19:47:52] info:    at System.Runtime.InteropServices.JavaScript.JSMarshalerArgument.ToManaged(ArraySegment`1& )
[19:47:52] info:    at System.Runtime.InteropServices.JavaScript.Tests.JavaScriptTestHelper.echo1_ArraySegmentOfInt32(ArraySegment`1 value, Boolean edit)
[19:47:52] info:    at System.Runtime.InteropServices.JavaScript.Tests.JSImportTest.JsImportArraySegmentOfInt32()
[19:47:52] info:    at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
[19:47:52] info:    at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object , BindingFlags )

GCHandle handle = (GCHandle)gcHandle;
var target = handle.Target!;
if (target is PromiseHolder holder2)
{
holder = holder2;
}
else
{
if (!ThreadJsOwnedObjects.Remove(target))

target can potentially be null, and it appears it was in this case.

Copy link
Contributor

Tagging subscribers to 'arch-wasm': @lewing
See info in area-owners.md if you want to be subscribed.

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Sep 6, 2024
@kg
Copy link
Contributor Author

kg commented Sep 6, 2024

cc @pavelsavara
Can target ever be null in a single threaded scenario? Or MT only?

@pavelsavara pavelsavara self-assigned this Sep 9, 2024
@pavelsavara pavelsavara added this to the 10.0.0 milestone Sep 9, 2024
@pavelsavara pavelsavara added os-browser Browser variant of arch-wasm and removed untriaged New issue has not been triaged by the area owner labels Sep 9, 2024
@pavelsavara
Copy link
Member

Probably duplicate #104470
It seems to me that Why are we setting the target on an unoccupied slot? #104524 could be also the same thing

@pavelsavara
Copy link
Member

Could this be the root cause ? #107974

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-wasm WebAssembly architecture area-System.Runtime.InteropServices.JavaScript os-browser Browser variant of arch-wasm
Projects
None yet
Development

No branches or pull requests

2 participants