Skip to content

check --dump-drop-state never finishes on a stage1 (test/phase/dump_drop_state_move.w): quadratic string concatenation while formatting the dump #1489

Closed

Description

@ehartford

test/phase/dump_drop_state_move.w (//! args: --dump-drop-state) times out on a stage1 built from origin/main ba2d5d1 (src/main build :dev, unmodified tree). The pinned seed runs the same check in 0.13 s.

src/main check test/phase/dump_drop_state_move.w --dump-drop-state                     # seed nightly-20260922: 0.13 s
out/bootstrap/bin/with-stage1 check test/phase/dump_drop_state_move.w --dump-drop-state  # >8 min, killed; the test runner's 300 s check limit fails it

sample of the running stage1, 20 s in, 2,492 samples on the main thread:

  • 1,246 in str_concat_n_copy
  • 886 in with_str_concat_n_move_first
  • 113 in munmap, called from rt_free_unlocked_with_drop_origin
  • MirDropStateMap.format, MirDropStateKeys.intern_chunk and MirDropStateBlocks.visit also appear in the stack

The dump text is built by repeated concatenation, which is quadratic, like ast in #1358. It only shows up when the dump covers a lot of code. Most likely stage1 formats the drop state of the embedded prelude bodies as well as the user file's functions (stage1 embeds the prelude modules), but this has not been confirmed.

Found while running the targeted tests for #1391. The failure is present on the unmodified base's stage1, so it does not come from that change. Expected: the dump is built in linear time, and a stage1 prints the same dump as the release binary.

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