Skip to content

Fix Io metadata reference after Builder move - #355

Merged
connormanning merged 1 commit into
connormanning:masterfrom
michael-her:fix/builder-move-io-metadata-ref
Jun 2, 2026
Merged

Fix Io metadata reference after Builder move#355
connormanning merged 1 commit into
connormanning:masterfrom
michael-her:fix/builder-move-io-metadata-ref

Conversation

@michael-her

Copy link
Copy Markdown
Contributor

Summary

  • Fix dangling Metadata& / Endpoints& in Io after Builder is move-constructed or move-assigned.
  • Laszip (and other Io implementations) capture references at construction; the compiler-generated move moved unique_ptr<Io> but left those references pointing at the moved-from Builder metadata (empty schema), causing chunk serialization to fail with Failed to find dimension: X.
  • Recreate io via Io::create(metadata, endpoints) in the move constructor and move assignment operator.
  • Add build.movedBuilderIoMetadata unit test: after std::move, io->metadata must alias moved.metadata and a full build still writes tiles.

Context

The CLI path Builder builder = builder::create(config) uses guaranteed copy elision and does not hit this bug. Embedding code that move-constructs Builder (e.g. std::make_shared<Builder>(builder::create(config))) does.

Test plan

  • build.movedBuilderIoMetadata — move alias + end-to-end build on ellipsoid.laz
  • CI unit tests (test/unit/build.cpp)

Io stores const Metadata& from Builder construction. When Builder is move-constructed, the default move leaves Laszip referencing the moved-from metadata (empty schema), breaking chunk serialization.

Recreate io from the new metadata and endpoints in move ctor/assign. Add unit test asserting io->metadata aliases moved.metadata.
@connormanning
connormanning merged commit ff9f2f2 into connormanning:master Jun 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants