vk icon indicating copy to clipboard operation
vk copied to clipboard

Incorrect calling convention on Android causes SIGABORT

Open TechPizzaDev opened this issue 3 years ago • 2 comments

The stdcall convention currently generated by the rewriter does not default to the correct platform convention under Mono, while it does work on CoreCLR (e.g. stdcall works on Linux even though it shouldn't).

The solution could be to either change the calling convention to unmanaged which should work everywhere. If performance is a concern, we could create a specialized dll in the Nuget package that gets used for Android.

TechPizzaDev avatar Jan 16 '22 01:01 TechPizzaDev

The Vulkan header which defines the calling convention: https://github.com/KhronosGroup/Vulkan-Docs/blob/v1.2.203/include/vulkan/vk_platform.h#L39-L59

Windows: stdcall Android 32-bit ARM: "the "hardfloat" calling convention" Everything else: "platform default"

The solution could be to either change the calling convention to unmanaged which should work everywhere.

What do you mean by unmanaged here? AFAIK (and it's been a while since I worked with the IL rewriter), these are the available calling conventions. They're modeled slightly differently in Mono.Cecil but they seem more or less the same.

mellinoe avatar Jan 16 '22 01:01 mellinoe

Right, I was looking at a decompilation produced by the rewriter, so you may not have been aware of function pointers in net5 as the source code has no mention of the modern C# function pointers. Seems that the IL rewriter produced something that Mono did not consume correctly in net6.

Quoting from the C# discord; "unmanaged is "platform default" and that's stdcall on Windows and cdecl elsewhere". Written either like delegate* unmanaged[CallConv]<T1, T2, ...> or delegate* unmanaged<T1, T2, ...>.

TechPizzaDev avatar Jan 16 '22 01:01 TechPizzaDev