Skip to content

Conversation

@Oblomov
Copy link

@Oblomov Oblomov commented Jan 2, 2026

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.

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.
@Oblomov Oblomov changed the title Fix stackframecreate Fix StackFrameCreate when the base stack pointer is larger than the max positive signed 16-bit integer Jan 2, 2026
@Oblomov Oblomov changed the title Fix StackFrameCreate when the base stack pointer is larger than the max positive signed 16-bit integer Fix StackFrameCreate when the base stack pointer is larger than the max positive signed 16-bit integer (I7-2382) Jan 2, 2026
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.

1 participant