-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Description
Hit this while running the triangle sample at https://github.com/MichalStrehovsky/sokol-csharp/blob/master/src/examples/triangle.cs.
triangle.exe!S_P_CoreLib_Interop_Ole32__CoTaskMemFree�() Unknown
triangle.exe!S_P_CoreLib_System_Runtime_InteropServices_Marshal__FreeCoTaskMem() Line 181 Unknown
triangle.exe!S_P_CoreLib_System_Runtime_InteropServices_Marshalling_Utf8StringMarshaller__Free() Line 49 Unknown
triangle.exe!Internal_CompilerGenerated__Module___<Cleanup>sokol_csharp_unofficial_Sokol_Gfx_BufferDesc�() Unknown
triangle.exe!sokol_csharp_unofficial_Sokol_Gfx__MakeBuffer_1�() Unknown
triangle.exe!sokol_csharp_unofficial_Sokol_Gfx__MakeBuffer_1�() Unknown
triangle.exe!sokol_csharp_unofficial_Sokol_Gfx__MakeBuffer_0<Single>�() Unknown
> triangle.exe!triangle_Program____Main___g__Init_0_0() Line 33 Unknown
[Inline Frame] triangle.exe!_sapp_call_init() Line 2322 C
triangle.exe!_sapp_frame() Line 2510 C
triangle.exe!_sapp_win32_run(const sapp_desc * desc) Line 6594 C
triangle.exe!sokol_csharp_unofficial_Sokol_App__Run�() Unknown
triangle.exe!triangle_Program___Main__() Line 6 Unknown
CoTaskMemFree is detecting corrupted memory. Stepping through the marshalling code, we never allocated any because it was stack allocated. To add insult to injury, it was also stack allocated in a frame that we left and overwrote.
I think this regressed in #69043 that added the optimized path without allocation. We need to not do the optimized path when marshalling an element of a struct.
We need to start running the Pri-0 interop tests ASAP. Now that the runtime repo completely migrated off DllImport, there's nothing in the libraries partition that would be testing built in marshalling and our smoke tests are lacking coverage.