Session

When FFI Tests Aren't Enough: Bringing Sanitizers to Dart Native Assets

A native Dart package can pass every functional test and still be one bad pointer lifetime away from crashing a Flutter app.

I ran into this while moving package:webcrypto onto Dart native assets. Its FFI layer wraps BoringSSL pointers, transfers ownership across scopes, and relies on Dart finalizers. The crypto worked, but ordinary tests could not prove that GC pressure, failed imports, or cleanup bugs would not expose native memory errors.

Valgrind gave us an immediate safety net. ASan should have been the next CI flag, but that exposed gaps between Dart build hooks, package:test, AOT compilation, and sanitizer runtimes. Appended AOT snapshots also made Dart symbols difficult for native symbolizers to reach.

That package problem led upstream into the Dart SDK. I added a Linux CLI bundle with one shared runtime and separate AOT snapshots, added ASan, MSan, and TSan support to package:test, and added SDK integration coverage using a real hook-built native asset.

Finally, we broke the C code deliberately and verified that ASan caught the heap-buffer-overflow through the same test path.

This session follows that path from webcrypto to package:test, native fixtures, and the Dart SDK: where FFI tests stop, how Valgrind and sanitizers complement each other, why the AOT layout mattered, and how package authors can build a useful native memory-safety CI lane with commands such as `dart test -c cli -p vm-asan`.

Hamdaan Ali

GenAI Engineer at Intuit | GSoC Mentor @Dart Org | Founding Engineer @Boost | Author @FreeCodeCamp MonSchool

Bengaluru, India

Actions

Please note that Sessionize is not responsible for the accuracy or validity of the data provided by speakers. If you suspect this profile to be fake or spam, please let us know.

Jump to top