Skip to content

bug: Function code ranges cannot represent callable entry points #115

Open

Description

@caverav

Environment

  • OS: Linux x86_64 host, ARM64 target
  • Input type: synthetic monomorphic fixture; not seen on LocalSend
  • Command: model and consumer probe from the review fixture; no CLI command reproduces it yet
  • flutterdec commit/tag: ab00bd76de5e7ba87e909e0b8d5e300edb86ddd9 (PR feat(serwalker): add the Dart 3.11.1 FullAOT adapter #74 head when the review was written)

What Happened

Function.code starts at the payload start, not at the callable entry. In the monomorphic fixture the function starts at 0x1010 while its Code-pool target is 0x1028. The exact-address join in build_function_metadata_lookup then misses the function, so the selector, owner, and library are lost. Selecting the function with EntryVa(0x1028) also fails.

The producer already has the decoded Code object, including entry_point and monomorphic_entry_point. produce_functions_info checks code.entry_point at crates/flutterdec-serwalker/src/info_producer/functions_info.rs:66-70, but it does not emit either entry into the model. The model's Function at crates/flutterdec-adapter/src/model.rs:466-481 has code: CodeRange and code_section_va, with no field for a callable entry. The range is intentionally the whole function: functions_info.rs:114-133 starts at the payload and covers the switchable-call-miss, monomorphic, and polymorphic entries.

Expected Behavior

The model should carry the callable entry or entries without dropping the full range. build_function_metadata_lookup should join on that value and keep the selector, owner, and library. EntryVa(0x1028) should select the monomorphic function. Two declarations that share one Code body should not get a unique owner.

Reproduction

  1. Build the monomorphic fixture from the review thread: payload 0x1010, Code-pool target 0x1028.
  2. Print Function.code.start_va and the pool target.
  3. Run the metadata join used by build_pool_semantic_hints (build_function_metadata_lookup at crates/flutterdec-core/src/pipeline/runners/symbols.rs:367-380); the function is not found.
  4. Select with EntryVa(0x1028) at crates/flutterdec-core/src/pipeline/runners.rs:1156-1160; selection fails.

The review thread has the decoder and consumer evidence: #74 (comment)

Additional Context

This is a model contract gap, not a producer bug. The gap predates PR #74, and the PR's producer keeps the full range. The reply in the thread says the same: the current Function cannot hold both the full range and the callable entry.

The fix changes the adapter model, so it needs a MODEL_VERSION bump from 4. That bump updates every producer, validator, fixture, and compatibility record. It also means old adapters are rejected. That is why it belongs in its own PR, not #74.

A single callable_entry_va is not enough. The range covers three entries (switchable-call-miss, monomorphic, polymorphic), so the model needs a Code entity, an entry table, or a field that names the entry kind. The issue is to choose that shape and implement it.

A stopgap is to put callable_entry_va in the existing serwalker.function.<id> extension and teach the consumer to read it. That avoids a version bump but stays producer-specific and untyped, so it is not the preferred fix.

Acceptance Tests

  1. The model can represent the callable entry, or entries, for a function.
  2. build_function_metadata_lookup joins on it and keeps the selector, owner, and library.
  3. EntryVa(0x1028) selects the function in the monomorphic fixture.
  4. Two Function declarations that share one Code body do not receive a unique owner.

Scope and Risks

Affected crates: flutterdec-adapter for the model and validation, flutterdec-serwalker for the producer, flutterdec-core for the metadata lookup and entry selection, plus fixtures and compatibility records. The model version bump means installed adapters from the old version are rejected. Test with the monomorphic fixture and a shared-code fixture.

Activity

  1. added
    bug
    on Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions