[PR #7201] [MERGED] Fix scoreboard division overflow for minimum integer #7407

Closed
opened 2026-11-03 06:39:06 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/7201
Author: @TheMrZZ
Created: 11/2/2026
Status: ✅ Merged
Merged: 11/2/2026
Merged by: @ludovic111

Base: main ← Head: fix/7196-scoreboard-division-overflow


📝 Commits (1)

  • 29a273d Fix scoreboard division overflow for minimum integer

📊 Changes

2 files changed (+23 additions, -2 deletions)

View changed files

📝 crates/horizon-client/src/scoreboard_cmd.rs (+2 -2)
📝 crates/horizon-client/src/scoreboard_cmd_tests.rs (+21 -0)

📄 Description

🤖 Opened by TheMrZZ's AI agent (T3 Code / Codex, gpt-6-astra), not by TheMrZZ personally.

What and why

Fixes #7196. Scoreboard division of -2147483648 by -1 must wrap to -2147483648. The quotient already wraps, but the remainder check panics. Use wrapping_rem in that check and add a command-level regression that verifies the target and unchanged divisor. The separate large-divisor remainder behavior is outside this change.

Kind

  • bug: a crash or a breakage

Vanilla reference

Official Java Edition 26.3: OperationArgument.getSimpleOperation calls Mth.floorDiv, which delegates to Math.floorDiv (verified in bytecode). A fresh official server, jar SHA-1 33680f5f2ac32864d6d7cf5e56a705fdb3e05f4c, processed the issue's commands, reported target has -2147483648 [poc], and accepted stop normally.

Built the port ledger from the official server jar, queried the issue and method, and ran port_ledger.py check --base origin/main: only this method is touched, with no new gaps reported.

Regression evidence on base 9eb0e230e34836c8c1e567593bc7123e66475f66:

  • New scoreboard_cmd::tests::division_wraps_minimum_integer_by_negative_one fails on old source at scoreboard_cmd.rs:792:48: remainder overflow.
  • With the fix, all 7 scoreboard command tests pass.
  • cargo test -p horizon-client-lib --lib: 1,385 passed, 48 ignored.
  • The exact old function also panics when compiled independently with rustc -O.

The regression uses the existing command unit-test module. A full Horizon server run was not performed here. Existing scoreboard parity harness execution remains for CI because the prepared client resources are unavailable locally.

Other projects' code

None. No Pumpkin implementation source was read or copied. This change follows independently observed vanilla behavior and official game bytecode.

Self-check

pr_ready (tools/pr_ready.py --base 9eb0e230e, against 9eb0e230e at 9eb0e230e, 3 min 29 s)

Check Result
Scope ✅ 2 files, +23 −2
Cargo.lock ✅ unchanged
Public tree ✅
Python tests ✅ 612 passed (55 s)
rustfmt ✅ (7 s)
clippy ✅ (1 min 14 s)
tests: horizon-client-lib ✅ 1434 passed (1 min 11 s)
doc tests ✅ 0 passed (2 s)
content root tests ➖ content root untouched
mod API up to date ➖ native hooks untouched
tokens.css up to date ➖ theme untouched
launcher rustfmt ➖ launcher untouched
launcher clippy ➖ launcher untouched
launcher tests ➖ launcher untouched
Parity ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses
Label player-facing: feature if players get something new, no label for a fix (release-now if urgent)

🤖 Generated with Codex in T3 Code.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/7201 **Author:** [@TheMrZZ](https://github.com/TheMrZZ) **Created:** 11/2/2026 **Status:** ✅ Merged **Merged:** 11/2/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/7196-scoreboard-division-overflow` --- ### 📝 Commits (1) - [`29a273d`](https://github.com/horizon-rust/horizon/commit/29a273d96e73b9606242ab39f034a1df17320893) Fix scoreboard division overflow for minimum integer ### 📊 Changes **2 files changed** (+23 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/scoreboard_cmd.rs` (+2 -2) 📝 `crates/horizon-client/src/scoreboard_cmd_tests.rs` (+21 -0) </details> ### 📄 Description > 🤖 Opened by TheMrZZ's AI agent (T3 Code / Codex, gpt-6-astra), not by TheMrZZ personally. ## What and why Fixes #7196. Scoreboard division of `-2147483648` by `-1` must wrap to `-2147483648`. The quotient already wraps, but the remainder check panics. Use `wrapping_rem` in that check and add a command-level regression that verifies the target and unchanged divisor. The separate large-divisor remainder behavior is outside this change. ## Kind - [x] bug: a crash or a breakage ## Vanilla reference Official Java Edition 26.3: `OperationArgument.getSimpleOperation` calls `Mth.floorDiv`, which delegates to `Math.floorDiv` (verified in bytecode). A fresh official server, jar SHA-1 `33680f5f2ac32864d6d7cf5e56a705fdb3e05f4c`, processed the issue's commands, reported `target has -2147483648 [poc]`, and accepted `stop` normally. Built the port ledger from the official server jar, queried the issue and method, and ran `port_ledger.py check --base origin/main`: only this method is touched, with no new gaps reported. Regression evidence on base `9eb0e230e34836c8c1e567593bc7123e66475f66`: - New `scoreboard_cmd::tests::division_wraps_minimum_integer_by_negative_one` fails on old source at `scoreboard_cmd.rs:792:48`: remainder overflow. - With the fix, all 7 scoreboard command tests pass. - `cargo test -p horizon-client-lib --lib`: 1,385 passed, 48 ignored. - The exact old function also panics when compiled independently with `rustc -O`. The regression uses the existing command unit-test module. A full Horizon server run was not performed here. Existing scoreboard parity harness execution remains for CI because the prepared client resources are unavailable locally. ## Other projects' code None. No Pumpkin implementation source was read or copied. This change follows independently observed vanilla behavior and official game bytecode. ## Self-check **pr_ready** (`tools/pr_ready.py --base 9eb0e230e`, against 9eb0e230e at 9eb0e230e, 3 min 29 s) | Check | Result | | --- | --- | | Scope | ✅ 2 files, +23 −2 | | Cargo.lock | ✅ unchanged | | Public tree | ✅ | | Python tests | ✅ 612 passed (55 s) | | rustfmt | ✅ (7 s) | | clippy | ✅ (1 min 14 s) | | tests: horizon-client-lib | ✅ 1434 passed (1 min 11 s) | | doc tests | ✅ 0 passed (2 s) | | content root tests | ➖ content root untouched | | mod API up to date | ➖ native hooks untouched | | tokens.css up to date | ➖ theme untouched | | launcher rustfmt | ➖ launcher untouched | | launcher clippy | ➖ launcher untouched | | launcher tests | ➖ launcher untouched | | Parity | ➖ not run (no vanilla data here): CI's parity job picks the affected harnesses | | Label | player-facing: `feature` if players get something new, no label for a fix (`release-now` if urgent) | 🤖 Generated with [Codex](https://openai.com/codex/) in T3 Code. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 06:39:06 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#7407
No description provided.