Skip to content

Source linked list uses 16-bit pointers — potential truncation like #473 #476

Description

@thedavidmeister

Description

newActiveSourcePointer in LibParseState.sol packs a memory pointer into 16 bits:

  • Line 224: shl(0x10, oldActiveSourcePointer) — stores pointer in bits 16+
  • Line 228: and(..., 0xFFFF) to store new pointer in low 16 bits
  • Line 495: shr(0xf0, mload(itemSourceHead)) — reads linked list next pointer

This is the same 16-bit pointer pattern that caused #473 in the sub-parser linked list. In practice, sources are allocated sequentially during a single parse so memory growth is bounded, but the constraint is implicit rather than enforced.

Should either:

  1. Widen the pointer bits (as done for sub-parsers in Fuzz failure: LibParseStateExportSubParsersTest #473), or
  2. Add an explicit check/comment documenting why 16 bits is safe for this specific use case

The shift should also use a named constant rather than magic numbers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions