@@ -27,11 +27,16 @@ final class Isolate extends Opaque {}
2727abstract class FfiBindings {
2828 static final ffiTestFunctions = dlopenPlatformSpecific ("ffi_test_functions" );
2929
30- static final IGH_MsanUnpoison = ffiTestFunctions
30+ static final IGH_CreatePeer = ffiTestFunctions
31+ .lookupFunction< Pointer <Void > Function (), Pointer <Void > Function ()> (
32+ 'IGH_CreatePeer' ,
33+ );
34+
35+ static final IGH_CheckPeerShutdown = ffiTestFunctions
3136 .lookupFunction<
32- Pointer < Isolate > Function (Pointer <Void >, IntPtr ),
33- Pointer < Isolate > Function (Pointer <Void >, int )
34- > ('IGH_MsanUnpoison ' );
37+ Void Function (Pointer <Void >),
38+ void Function (Pointer <Void >)
39+ > ('IGH_CheckPeerShutdown ' );
3540
3641 static final IGH_CreateIsolate = ffiTestFunctions
3742 .lookupFunction<
@@ -82,7 +87,6 @@ abstract class FfiBindings {
8287 Pointer <Void > peer,
8388 ) {
8489 final cname = name.toNativeUtf8 ();
85- IGH_MsanUnpoison (cname.cast (), name.length + 10 );
8690 try {
8791 final isolate = IGH_CreateIsolate (cname, peer);
8892 Expect .isTrue (isolate.address != 0 );
@@ -105,9 +109,7 @@ abstract class FfiBindings {
105109 );
106110 final dartScript = dartScriptUri.toString ();
107111 final libraryUri = dartScript.toNativeUtf8 ();
108- IGH_MsanUnpoison (libraryUri.cast (), dartScript.length + 1 );
109112 final functionName = name.toNativeUtf8 ();
110- IGH_MsanUnpoison (functionName.cast (), name.length + 1 );
111113
112114 IGH_StartIsolate (
113115 isolate,
@@ -137,23 +139,14 @@ void scheduleAsyncInvocation(void fun()) {
137139}
138140
139141Future withPeerPointer (fun (Pointer <Void > peer)) async {
140- final Pointer <Void > peer = 'abc' .toNativeUtf8 ().cast ();
141- FfiBindings .IGH_MsanUnpoison (peer.cast (), 'abc' .length + 1 );
142+ final Pointer <Void > peer = FfiBindings .IGH_CreatePeer ();
142143 try {
143144 await fun (peer);
144145 } catch (e, s) {
145146 print ('Exception: $e \n Stack:$s ' );
146147 rethrow ;
147148 } finally {
148- // The shutdown callback is called before the exit listeners are notified, so
149- // we can validate that a->x has been changed.
150- Expect .isTrue (peer.cast <Utf8 >().toDartString ().startsWith ('xb' ));
151-
152- // The cleanup callback is called after notifying exit listeners. So we
153- // wait a little here to ensure the write of the callback has arrived.
154- await Future .delayed (const Duration (milliseconds: 100 ));
155- Expect .equals ('xbz' , peer.cast <Utf8 >().toDartString ());
156- calloc.free (peer);
149+ FfiBindings .IGH_CheckPeerShutdown (peer);
157150 }
158151}
159152
0 commit comments