Skip to content

Suppress Valgrind false positive and enable 2D array support#70

Merged
shekohex merged 2 commits into
masterfrom
copilot/fix-dea96db4-9656-499e-b5fd-5e9ec97ed096
Sep 2, 2025
Merged

Suppress Valgrind false positive and enable 2D array support#70
shekohex merged 2 commits into
masterfrom
copilot/fix-dea96db4-9656-499e-b5fd-5e9ec97ed096

Conversation

Copilot AI commented Sep 1, 2025

Copy link
Copy Markdown
Contributor

This PR addresses the Valgrind memory leak false positive that was blocking PR #66 and includes the 2D array functionality from that PR.

Problem

PR #66 introduced support for 2D arrays like [[A; N]; M] but caused the CI to fail due to a Valgrind memory leak detection. Investigation showed this was a false positive related to Rust's random number generator initialization:

==16893== 48 bytes in 1 blocks are possibly lost in loss record 3 of 62
==16893==    at 0x484680F: malloc (vg_replace_malloc.c:446)
==16893==    by 0x2AFC57: alloc (alloc.rs:93)
==16893==    by 0x2AFC57: alloc_impl (alloc.rs:188)
==16893==    by 0x2AFC57: allocate (alloc.rs:249)
==16893==    by 0x2AFC57: {closure#0}

The stack trace shows this originates from fastrand::global_rng::RNG initialization, which is a known false positive in Rust applications.

Solution

  1. Added Valgrind suppressions file (valgrind.supp) to suppress the false positive memory leak from Rust's allocator initialization
  2. Updated CI workflow to use --suppressions=valgrind.supp in the Valgrind command
  3. Implemented 2D array support by adding IntoDartExceptPrimitive for [T; N] arrays (from PR Fix [[A; N]; M] cannot be used with allo isolate #66)
  4. Added test coverage for 2D array functionality using boolean arrays

Testing

The fix was verified by:

  • ✅ Building successfully with the new array implementation
  • ✅ Running unit tests that pass
  • ✅ Confirming Valgrind fails without suppressions (exit code 1)
  • ✅ Confirming Valgrind passes with suppressions (exit code 0)
  • ✅ Testing 2D array functionality works correctly

Example Usage

With these changes, 2D arrays now work correctly:

let arr_2d: [[bool; 3]; 2] = [[true, false, true], [false, true, false]];
assert!(isolate.post(arr_2d)); // Now works!

Fixes the issue described in fzyzcjy/flutter_rust_bridge#2703

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: shekohex <14620076+shekohex@users.noreply.github.com>
Copilot AI changed the title [WIP] Hey could you suppress the above error https://github.com/shekohex/allo-isolate/pull/66#issuecomment-2887855705 and from the CI https://github.com/shekohex/allo-isolate/actions/runs/15070928728/job/42366794103?pr=66 Look into the PR #66 and the full c... Suppress Valgrind false positive and enable 2D array support Sep 1, 2025
Copilot AI requested a review from shekohex September 1, 2025 18:24
@shekohex
shekohex marked this pull request as ready for review September 1, 2025 18:34
@shekohex

shekohex commented Sep 2, 2025

Copy link
Copy Markdown
Owner

Original Code by @fzyzcjy btw.

@shekohex
shekohex merged commit 9134004 into master Sep 2, 2025
15 checks passed
@shekohex
shekohex deleted the copilot/fix-dea96db4-9656-499e-b5fd-5e9ec97ed096 branch September 2, 2025 11:53
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.

2 participants