<div dir="ltr">Hi All,<div><br></div><div>    the latest VMs support a new facility which catches and reports exceptions during FFI calls as primitive failures.  That means that if you have the relevant support code loaded (described below) and depending on dialect, you write your FFI interface method to contain an error code, or you're using the UnifiedFFI which uses invokeWithArguments:, then any exception that occurs during the FFI call will be caught and reported to use with the error code bound to an instance of ExceptionInFFICall, which contains a platform-specific error code and the pc at which it occurred.</div><div><br></div><div>To use this facility you'll need to download a VM built yesterday or later (it should be derived from VMMaker.oscog-eem.2435 or later), or build your own from the tip of the Cog branch in opensmalltalk/vm.  You'll then need to update the image code to install ExceptionInFFICall appropriately:</div><div>in Pharo6 load SLICE 22367</div><div>in Squeak load the latest FFI code from <a href="http://source.squeak.org/FFI">source.squeak.org/FFI</a> and update your image from trunk</div><div>in Cuis, you'll need to adapt these changes to Cuis (sorry!!)</div><div><br></div><div>There are two command-line flags to override the default behavior.  [-]-failonffiexception causes the handling to be applied to all FFI calls, so if a method doesn't contain an error, you'll just see a primitive failure, and if ExceptionInFFICall is not installed you'll see only an error number in the call's error code.</div><div><br></div><div>[-]-nofailonffiexception ignores exceptions during FFI calls, hence defaulting to the old behavior of crashing the VM (which may be useful if one is using a low-level debugger to debug the VM and/or external code).</div><div><br></div><div>HTH<br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div></div>