ericsink / SQLitePCL.raw

A Portable Class Library (PCL) for low-level (raw) access to SQLite
Apache License 2.0
512 stars 106 forks source link

FEATURE_FUNCPTRS/plain breaks when targeting net6.0+ on Windows #573

Closed filipnavara closed 7 months ago

filipnavara commented 7 months ago

FEATURE_FUNCPTRS/plain was introduced in commit https://github.com/ericsink/SQLitePCL.raw/commit/9adcbfce7ba69450d3173f2d129a468023279042 to workaround a bug in iOS AOT compiler. That bug was fixed in .NET 7 and .NET 8 and so the workaround is no longer necessary. We should use FEATURE_FUNCPTRS/callingconv again for generic .NET 6+ platforms.

The issue is that compiling a unit test assembly against generic net6+ target and referencing SQLitePCLRaw.provider.e_sqlite3 on Windows results in using the generic net6.0 version from the NuGet package. That assembly version is missing the CDecl calling convention decorations on UnmanagedCallersOnly attributes and thus results in incorrect calling convention used on x86 platforms. This can be observed when using sqlite3_create_function to register custom functions since the callbacks corrupt the stack and result in access violation.

ericsink commented 7 months ago

This was included in 2.1.7, which has been pushed up to nuget.