Skip to content

bool return from PInvoke misinterpreted on Alipine #36372

@swaroop-sridhar

Description

@swaroop-sridhar

On linux-musl-release-x64 builds, the return value from a native function returning false is sometimes incorrectly interpreted as true because of the mismatch between the number of bytes expected for bool on native and managed sides.

Repro:
The host defines a native function bundle_probe with type

bool STDMETHODCALLTYPE bundle_probe(const char16_t* path, int64_t* offset, int64_t* size)

If this function is called from managed code using the following delegate:

 [UnmanagedFunctionPointer(CallingConvention.StdCall)]	        
 public delegate bool BundleProbeDelegate([MarshalAs(UnmanagedType.LPWStr)] string path, IntPtr size, IntPtr offset);

The invocations where bundle_probe return false, are interpreted as true. Gor example:

Probe(bundleProbeDelegate, "", isExpected: false);

Once this issue is fixed, this test asset should be updated to use the bool return type in the PInvoke delegate.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions