Skip to content

fix: prevent tilemap coordinate overflow - #2009

Merged
joeykchen merged 1 commit into
goplus:devfrom
joeykchen:fix/tilemap-coordinate-overflow
Sep 28, 2026
Merged

joeykchen merged 1 commit into
goplus:devfrom
joeykchen:fix/tilemap-coordinate-overflow

Conversation

@joeykchen

Copy link
Copy Markdown
Contributor

Tile placement multiplied int32 coordinates before widening: 67108864 * 64 became zero instead of 4294967296. Bounds also overflowed at MaxInt32+1 and MinInt32-1.

Perform coordinate and bounds arithmetic in int64, then check that returned dimensions and runtime-consumed edges fit int before narrowing. Unrepresentable bounds return the existing false result. A second cleanup replaces four repeated min/max branches with built-ins. Compact records, sorting, callback order, and negative tile-size conventions remain unchanged.

Validation: new placement and extreme-boundary regressions fail on the old implementation and pass after the fix. Native tilemap/root tests, pure tilemap tests/root compilation, wasm root compilation, and Linux 386 pure tilemap compilation pass with Go 1.26.5. A native-only overlay additionally exercises simulated 32-bit range rejection; no execution of a 386 binary is claimed.

Runtime metadata was regenerated twice. Source patches combine cleanly with #2003; regenerate export.types with make generate-runtime when combining pending runtime PRs.

Combined validation of all five fixes passed with Go 1.26.5: 79 host packages, codegen and interpreter submodules, pure/wasm root compilation, and actual Web binding wasm tests. Two full generation runs produced identical diffs; all six external Godot outputs were unchanged.

@fennoai fennoai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the complete fixed range 03576e6c0bbead9e73736482539dd321f5521206...21e96c06419853a66ce74ac93566582bf1a0e3fb, including the generated runtime metadata. Focused validation passes with go test ./internal/tilemap and go test .; the attempted 386 test build is blocked by pre-existing missing native binding symbols outside this diff.

No concrete, actionable correctness or regression issues were found in the changed tilemap arithmetic, bounds handling, generated metadata, or call-site integration. The patch is correct based on the fixed diff and the passing focused host tests.

@joeykchen
joeykchen force-pushed the fix/tilemap-coordinate-overflow branch from 21e96c0 to 8e0874f Compare September 28, 2026 03:39
@joeykchen
joeykchen merged commit c31a699 into goplus:dev Sep 28, 2026
5 checks passed
@joeykchen
joeykchen deleted the fix/tilemap-coordinate-overflow branch September 28, 2026 04:23
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