Skip to content

ci: add FFI memory-safety test lane#295

Merged
HamdaanAliQuatil merged 3 commits into
masterfrom
ffi-memory-safety
Jul 5, 2026
Merged

ci: add FFI memory-safety test lane#295
HamdaanAliQuatil merged 3 commits into
masterfrom
ffi-memory-safety

Conversation

@HamdaanAliQuatil

@HamdaanAliQuatil HamdaanAliQuatil commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Closes #278

This adds a focused memory-safety workload for the native FFI path and runs it under Valgrind on Linux CI.

The implementation is split into:

  • test/ffi/valgrind_test.dart: a VM-only test that skips outside Linux or when Valgrind is unavailable, then launches
    the standalone target under Valgrind.
  • test/ffi/valgrind_target.dart: a standalone Dart program without package:test, keeping the monitored process
    focused on native crypto operations and memory pressure.

What this covers:

  • AES-GCM, HMAC, ECDH, and RSA-OAEP operations through the public API.
  • Key export/import ownership paths for raw, JWK, PKCS8, and SPKI formats.
  • Failed native imports followed by valid operations, exercising cleanup-after-error paths.
  • Repeated short-lived allocations between native operations to put pressure on Dart object lifetimes and finalizers.

The CI job uses the normal dart test path because it supports native build hooks today. Sanitizer support for hook-
built code remains blocked upstream, so this starts with Valgrind Memcheck.

Valgrind reports definite and possible leaks but only fails on definite leaks. Possible leaks can include Dart VM
runtime noise, so they remain visible without making the initial CI lane unnecessarily brittle.

Comment thread test/ffi_memory_safety_test.dart Outdated
@HamdaanAliQuatil HamdaanAliQuatil requested a review from jonasfj July 4, 2026 12:46

@jonasfj jonasfj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should consider avoiding the extra GitHub actions job if not strictly necessary

Comment thread test/ffi/valgrind_test.dart
Comment thread .github/workflows/test.yml
Comment thread test/ffi/valgrind_target.dart
@HamdaanAliQuatil HamdaanAliQuatil merged commit 3cd422c into master Jul 5, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FFI safety: add valgrind and memory-pressure testing

2 participants