Skip to content

Analysis Fails on Dart 3.10.3 with Temporary Register Usage in Parameter Handling #184

@karjok

Description

@karjok

Hello,

While performing static analysis on a Flutter application using your amazing project, blutter, the tool crashes with a segmentation fault when encountering a specific register shuffling pattern in the function prologue.

Error Output:

Analysis error at line 1668 `void FunctionAnalyzer::handleParameterRegisters(AsmIterator &)`: !isTmpReg
    0x7ad704: mov x2, x1
    0x7ad708: mov x1, x16
    0x7ad70c: mov x16, x3
    0x7ad710: mov x3, x2
  * 0x7ad714: mov x2, x16
    0x7ad718: stur x2, [x29, #-0x10]
...
subprocess.CalledProcessError: Command '[...]' died with <Signals.SIGSEGV: 11>.

Root Cause:

The crash occurs in /blutter/src/CodeAnalyzer_arm64.cpp at line 1668, where an assertion !isTmpReg fails. The issue is that the current analysis doesn't track values through temporary registers (x16/IP0 and x17/IP1).

In the observed assembly sequence:

  1. x16 (TMP) temporarily holds the value from x3
  2. This value is then moved to x2
  3. The assertion fails because the analyzer doesn't expect temporary registers in parameter tracking

Temporary Workaround:

I've temporarily resolved this by modifying the code to skip tracking when encountering temporary registers:

// INSN_ASSERT(!isTmpReg);
if (isTmpReg) {
    // Skip tracking this parameter properly for now
    ++insn;
    continue;
}

Suggested Fix:

The analysis should be enhanced to track values through temporary registers. When encountering mov x2, x16 where x16 is marked as TMP, the analyzer should trace back to find where x16 obtained its value (in this case, from mov x16, x3) and treat x2 as originating from x3.

Environment:

  • Dart version: 3.10.3
  • Snapshot: 1ce86630892e2dca9a8543fdb8ed8e22
  • Target: android arm64

Thank you for your amazing work !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions