Skip to content

Execute component start sections during instantiation or reject them #8

Description

@JairusSW

Problem

The binary decoder parses section 9 and stores it in Component.Start, but the component instantiation paths do not read or execute that field. A component containing a start section therefore instantiates as though the section were absent.

Relevant code:

The decoder also overwrites c.Start if multiple start sections occur, rather than rejecting a component with more than one start declaration.

Impact

A valid component can depend on its start function to initialize memory/state and produce the values consumed by later definitions. Skipping it can expose uninitialized state, bind later definitions incorrectly, or make exports behave differently from a conforming engine while instantiation reports success.

For a feature the runtime does not yet implement, silent omission is worse than a deterministic unsupported-feature error.

Suggested fix

Either:

  1. implement start-section validation and execution at the correct point in component instantiation, including argument/result typing, index-space resolution, trap propagation, and one-time execution; or
  2. reject any non-nil Component.Start before mutating runtime state until support is complete.

Also reject a second start section during decode/validation rather than replacing the first.

Regression tests

  • A component whose start function mutates state observed by an exported function must expose the initialized value.
  • A trapping start must make instantiation fail and clean up already-created core modules/resources.
  • The start function must run exactly once per instance, including cached/repeated instantiation.
  • A component with two start sections must be rejected.
  • Until implemented, all of the above should fail at validation with an explicit unsupported-start error rather than instantiate successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions