Fix StackFrameCreate when the base stack pointer is larger than the max positive signed 16-bit integer (I7-2382)#188
Open
Oblomov wants to merge 2 commits intoganelson:masterfrom
Open
Conversation
Building stories with a significant (but not excessive) number of objects (e.g. long tables) may lead to an I7SFRAME value that overflows the signed 16-bit signed maximum positive value, even though the pointer itself would still be valid. When this happens, the subsequent signed check in StackFrameCreate would lead to a memory allocation failure on the first stack frame creation even if it was a 0 byte allocation. Using an unsigned comparison avoids this issue. A similar fix was proposed for an older version of Inform7 in this thread over at IF forum: https://intfiction.org/t/memory-allocation-error-z-code-vs-blank-story-tab-glulx/60213/23 In my proposed patch, there is an additional check to prevent the proposed new pointer from ever becoming “truly” negative by making sure that the byte size WORDSIZE*size is not larger than I7SFRAME. Note that this patch APPARENTLY breaks test Chapter7-G, but looking at the history of this test, it appears that in commit 61534b3 (Reform of pointer-value kind support and Neptune) a significant fraction of the original log was replaced by a MemoryAllocationFailed error. I posit that this commit is fixing an issue introduced by that commit. A restoration of the original expected output will be included in a later change.
As discussed in the previous commit, this had gotten clobbered in commit 61534b3 Only one change is introduced compared to the original log: the implicit action (Jim first taking the pyramid of empty beer bottles) is removed because the pyramid of empty beer bottles is fixed and cannot be taken.
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.
Fix an issue related to the use of signed comparison in StackFrameCreate, and restore a test case whose reference log had gotten mangled in some previous commit due to a related error message. The details are in the first commit.