I7: Glulxe fatal error

After a few battles I’ve got my game to compile. After a couple of moves the game crashes with the following error

Glulxe fatal error: Memory access out of range (-215231EF)

Can anyone point me in the direction of what might be causing this?

That isn’t enough information for us to guess.

Are you using extensions? I6 code? Extensions that use I6 code?

Sorry, I’m not a programmer so had no idea what might even be causing this type of error. I think I have tracked it down.

In the code I have a couple of lines like the following early in the game -

choose row with a reply of "Roger Jones" in the Table of Word Crew;
blank out the whole row;

“Table of Word Crew” is a single column table with about 12 entries, the column being called simply “reply”.

Comment out this lines and the game works, leave it in and it crashes. Similar lines of code are working elsewhere in the game though.

That’s legitimate code, so something else must be wrong.

(It could be a bug in the 6L02 library code, not your fault, of course.)

Interestingly enough, this exact error is reported https://intfiction.org/t/inform-7-6l38-third-party-extension-compatibility-list/6821/2 here as being related to Achievements.

That’s certainly suspicious. Also gives me some code to test, so I’ll take a look at it. (Possibly not today.)

FWIW, the Achievements crash happens because of this I7 code:

Table of Achievements
message (text)		points (a number)		used (a number)
--		--		--

To score the achievement with message (msg - text):
	choose row with message of msg in the Table of Achievements;
	if the used entry is 0:
		now the used entry is the turn count;
		increase the score by the points entry.

...

After opening the wooden door, score the achievement with message "finding the way to the dining hall".

Table of Achievements (continued)
used		points		message
0		10		"finding the way to the dining hall"

Which produces the line

 ct_0 = T2_achievements; ct_1 = TableRowCorr(ct_0, 107, BlkValueCopy(I7SFRAME, t_0));

In the function KERNEL_6 :

[spoiler][code]
! From “Achievements” by Mikael Segercrantz
! Request 2: phrase text -> nothing
! To score the achievement with message ( msg - text ):
[ PHR_819_r2
t_0 ! Call parameter ‘msg’: text
I7RBLK;
@push I7SFRAME;
StackFrameCreate(2);
BlkValueCreateOnStack(0, TEXT_TY);
I7RBLK = KERNEL_6(t_0);
BlkValueFreeOnStack(0);
@pull I7SFRAME;
return I7RBLK; ! nothing
];
[ KERNEL_6
t_0 ! Call parameter ‘msg’: text
ct_0 ! currently selected table
ct_1 ! currently selected row
;
! [1: choose row with message of msg in the table of achievements]
ct_0 = T2_achievements; ct_1 = TableRowCorr(ct_0, 107, BlkValueCopy(I7SFRAME, t_0));
! [2: if the used entry is 0 begin]
if (((TableLookUpEntry(ct_0,109,ct_1) == 0))){
! [3: now the used entry is the turn count]
TableLookUpEntry(ct_0,109,ct_1,1,turns);
! [4: increase the score by the points entry]
score = score + TableLookUpEntry(ct_0,108,ct_1);;
! [5: end if]
}

    rfalse;

];

! After opening the wooden door:
[ R_830 I7RBLK;
@push I7SFRAME;
StackFrameCreate(2);
BlkValueCreateOnStack(0, TEXT_TY);
I7RBLK = KERNEL_2();
BlkValueFreeOnStack(0);
@pull I7SFRAME;
return I7RBLK; ! nothing
];
[ KERNEL_2 ;
if ((((action ==##Open) && (actor==player) && ((noun == I126_wooden_door) && (true))))) { ! Runs only when pattern matches
self = noun;
if (debug_rules) DB_Rule(R_830, 830);
! [1: score the achievement with message ~finding the way to the dining hall~]
(PHR_819_r2 (BlkValueCopy(I7SFRAME, TX_L_50)));
RulebookSucceeds(); rtrue;
} else if (debug_rules > 1) DB_Rule(R_830, 830, ‘action’);
rfalse;
];

Constant TX_PS_50 = “finding the way to the dining hall”;
Array TX_L_50 --> CONSTANT_PACKED_TEXT_STORAGE TX_PS_50;

[/code][/spoiler]

Just an update, I hadn’t spotted something. It is not these particular lines of code causing the problem as such, it is the fact in the first location I call the same lines twice.

choose row with a reply of "Ann Taylor" in the Table of Word Crew;
blank out the whole row;

and then later in the same block of code.

choose row with a reply of "Roger Jones" in the Table of Word Crew;
blank out the whole row;

Which ever of these are commented out makes the game work, leaving both in causes the error. It is the only place in the game I call the same table twice, every other location is only once.

This seems to have something to do with table continuations. I have a minimal case; filing bug.

EDIT-ADD: inform7.com/mantis/view.php?id=1255

EDIT-AGAIN: Actually, tables with blank rows. Which can be caused by table continuations.

As a workaround sorting the table before use seems to do the trick.

sort the Table of Word Crew in reply order

Yeah. The problem occurs if the search finds a blank entry in a column with a block-allocated type. Sorting puts blank rows at the bottom, so the search is fine – if it finds a row. (If you search for a value that has no corresponding row, it’ll run down into the blank entries and crash.)

Turns out 6G60 had this bug too, but it only showed up if you were searching a column which was indexed text or stored action or some other allocated type. In 6L02, all text is block-allocated so the bug occurs in many more situations.