MochiLibraries / Biohazrd

A framework for automatically generating binding wrappers for C/C++ libraries
MIT License
60 stars 8 forks source link

Provide an analyzer to detect incorrect function pointer invocation when marshaling is disabled #234

Open PathogenDavid opened 2 years ago

PathogenDavid commented 2 years ago

Relates to https://github.com/MochiLibraries/Biohazrd/issues/233

Having marshaling disabled introduces an awkward situation for function pointers which cross assembly bounds. If a function pointer from a no-marshaling assembly is invoked from a legacy yes-marshaling assembly the invocation may fail at runtime.

In order to guide Mochi consumers to correct behavior we should introduce an analyzer to detect bad situations and warn developers that they either need to apply DisableRuntimeMarshalling or use some other sort of workaround.

In the simplest form, this would be an analyzer which warns when a yes-marshaling assembly references a no-marshaling assembly.

In a more complex form it would check if a yes-marshaling assembly accesses a function pointer from a no-marshaling assembly.