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

Incorrect calling convention on Android causes SIGABORT #32

Open
TechPizzaDev opened this issue Jan 16, 2022 · 2 comments
Open

Incorrect calling convention on Android causes SIGABORT #32

TechPizzaDev opened this issue Jan 16, 2022 · 2 comments

Comments

@TechPizzaDev
Copy link

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.

@mellinoe
Copy link
Owner

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.

@TechPizzaDev
Copy link
Author

TechPizzaDev commented Jan 16, 2022

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, ...>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants