macOS library validation fails for FFI

It looks like #38288 has started happening again.

  1. Clone https://github.com/dart-lang/samples
  2. open the ffi/hello_world sample
  3. run cd c && make dylib
  4. run cd .. && dart hello.dart
  5. observe “Failed to load dynamic library” exception
dart hello.dart 
Unhandled exception:
Invalid argument(s): Failed to load dynamic library (dlopen(hello_world.dylib, 1): no suitable image found.  Did find:
	hello_world.dylib: code signature in (hello_world.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.)
#0      _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:10:55)
#1      new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:17:12)
#2      main (file:///Users/ryjohn/code/github/dart-lang/samples/ffi/hello_world/hello.dart:17:36)
#3      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:305:19)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:172:12)

cc: @mit-mit @mjohnsullivan

Author: Fantashit

1 thought on “macOS library validation fails for FFI

  1. I have a slightly different error:

    Failed to load dynamic library (dlopen(./hello_library/libhello.dylib, 1): no suitable image found. Did find:
    file system relative paths not allowed in hardened programs)

    Update:
    Fixed with executing
    codesign --remove-signature /usr/local/bin/dart

Comments are closed.