Skip to content

Fix saveSplatToPly int32 overflow for clouds with >35M gaussians - #104

Merged
ProjitB merged 3 commits into
nianticlabs:mainfrom
sung-ns:spz-overflow-fix
Aug 5, 2026
Merged

ProjitB merged 3 commits into
nianticlabs:mainfrom
sung-ns:spz-overflow-fix

Conversation

@sung-ns

@sung-ns sung-ns commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Problem

saveSplatToPly stored the point count as int32_t. The total buffer
size N * D (where D = 17 + shDim*3 fields per point) overflows
INT32_MAX at around 35M gaussians with SH degree 3, causing a corrupt
allocation and a crash or silent truncation.

Changes

  • int32 → int64: N, shDim, D, outIdx, and loop variables
    in saveSplatToPly are widened to int64_t, eliminating the
    overflow. The new theoretical limit (~150 quadrillion points at SH
    degree 3) is not a practical concern.

  • Structural reorder: file open and header write moved before the
    data loop, preparing for streamed output.

  • Chunked writing: data is written in 1M-point chunks instead of
    one monolithic allocation. For a 35M-point SH degree 3 cloud this
    reduces peak working buffer from ~8.7 GB to ~248 MB. The buffer is
    reused across chunks, so normals (always zero) are now written
    explicitly rather than relying on zero-initialisation.

Credit

Original fix is credited to Daniyar Turmukhambetov.

@lukeyreyno
lukeyreyno self-requested a review August 5, 2026 21:58
@ProjitB
ProjitB merged commit affd0ec into nianticlabs:main Aug 5, 2026
18 checks 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.

3 participants