Repository navigation
fix(runtime): prevent scripted item corruption, truncated-string leaks, and lost pixel writes (7/10) - #18
Open
shlifedev wants to merge 1 commit into
Open
fix(runtime): prevent scripted item corruption, truncated-string leaks, and lost pixel writes (7/10)#18shlifedev wants to merge 1 commit into
shlifedev wants to merge 1 commit into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three independently reproduced defects found during a parallel stability review of the shared game engine and native runtime:
dropscript changesTCitem, producing duplicated items and negative quantities. Instance-leveldropvetoes were also queued instead of executing before the transfer.ReadStringcan append uninitialized heap bytes after reading a truncated payload, and allocates the entire declared length before receiving any payload.Changes are shared by Stranded II and Extended. No edition resources, saved settings, reflection cadence, grass density, view distance, or release configuration are changed. Existing local renderer work was preserved and excluded.
Review coverage
This is a targeted review, not proof that every gameplay or platform path is defect-free. Already merged B3D/audio/Replace fixes and open #12/#15 were not duplicated.
Reproduction and changes
1. Scripted item transfers
exchange_item()runs scripts which may create, delete, consume, move, or select items, then previously reused the globalTCitempointer unchanged.In an actual native Blitz fixture, transferring a stack of five type-1 items whose
dropcallback creates one type-2 item left the original stack in place, changed the new item's quantity to -4, and created five type-2 items in storage.droptasks throughparse_sel()before applying the transfer, preserving veto return codes and the definition callback order.2. Truncated length-prefixed strings
With a declared length of 16 and only
ABCin the payload, the original nativeReadStringreturned a 16-byte string. With allocator scribbling enabled, its last 13 bytes were all 0xAA, proving that unreceived heap contents entered the result.This does not make every malformed map/save valid or safe to load; it fixes this runtime string-reading defect.
3. RGB10A2 framebuffer writes
uploadData()previously returned immediately for wide-format canvases, soWritePixel,WritePixelFast, andCopyPixeledits never reached the framebuffer.The same new Metal fixture fails four assertions against the original runtime and passes after the fix. This is a public framebuffer API compatibility defect. The game's potential dot-particle callers are currently disabled; ordinary rain/snow or campaign breakage was not established.
Validation
Completed on macOS ARM64:
dev.py build --platform macosanddev.py check --platform macos --suite fullpassed: 204 full-game checks, actual Metal rendering/readback and timestamp profiling, isolated save/bundle preservation, and 613 bytes matching the original Blitz3D 1.118 ABI reference.INT_MAXdeclarations with tiny/empty payloads.git diff --checkpassed. The user-maintained Korean README remains untouched.Not completed:
Score rationale
7/10. Actual runtime fixtures reproduce inventory corruption and uninitialized string data, and the GPU regression has a failing original-runtime control. The fixes preserve normal binary/numeric behavior and avoid speculative optimization. Platform and full-playthrough coverage remain incomplete, and the framebuffer issue has not been shown to affect ordinary base-game play.