Skip to content

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

Open
@kg

Description

@kg

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions