curiousdannii-testing / inform7-imported-bugs

0 stars 0 forks source link

[I7-2010] [Mantis 2046] "undo" after replay input crashes Glulx interpreter #74

Closed curiousdannii-testing closed 2 years ago

curiousdannii-testing commented 2 years ago

Reported by : turthalion

Description :

Compiled using Inform v6.33 Library v6.12.1 S).

After I replay a command script, even one of only one command, issuing "undo" causes Git and Glulxe report:
Reference to non-existent Glk object

Lectrote is, as expected more helpful, showing:
Quixe run: glk_get_line_stream: invalid stream

If, without replaying, I take the same command, I can type it in, hit and then type 'undo' and nothing untoward happens.

I've got a minimal example (attached) that demonstrates this.

If it is compiled with -~D in any way, then it crashes when you type undo after inputting a replay file.

in parserm.h in GGRecoverObjects (line 6491 in mine), there's the following:

#Ifdef DEBUG;
gg_commandstr = 0;
gg_command_reading = false;
#Endif; ! DEBUG

and a bit further down inside the switch sstatement (line 6503):
#Ifdef DEBUG;
GG_COMMANDWSTR_ROCK: gg_commandstr = id;
gg_command_reading = false;
GG_COMMANDRSTR_ROCK: gg_commandstr = id;
gg_command_reading = true;
#Endif; ! DEBUG

So we only wipe gg_commandstr and clear gg_command_reading when it's a debug build (which, unsurprisingly, is when it works properly for me, not crashing). If it's a release build, gg_commandstr is not cleared.

During discussion at intfiction.org (thread: https://www.intfiction.org/forum/viewtopic.php?f=7&t=25197&p=138447), zarf had the following to say:
"I don't know why the gg_commandstr lines in GGRecoverObjects() are conditionalized with "#ifdef DEBUG". There's no good reason for that, except maybe the expectation that the RECORD command will only be used on debug builds, which is not a good assumption. You can just remove the "#ifdef" lines there."

So I thought I'd post this here and see if anyone knows of a reason those #Ifdefs are there. I can verify that removing both sets seems to address my issue.

Steps to reproduce :

Constant Story "Test bed";
Constant Headline
    "^An Interactive Tester^
    No copyright asserted^";

Release 0; Serial "171223";

Include "Parser";
Include "VerbLib";

Object  garden "Beautiful Garden"
  with  description "An apple tree provides shade. The kitchen lies east.",
e_to Kitchen,
  has   light;

Object -> "feather"
  with  name 'feather',
description "It's a feather.";

Object  kitchen "Kitchen",
  with  description "This is a large country-style kitchen.",
w_to Garden,
  has   light;

Object  ->  plain_bag "plain shopping bag"
    with    name 'plain' 'shopping' 'bag',
            description "A plain shopping bag that can hold 2 things.",
      capacity 2,
      has open container;

Object -> "fork"
  with  name 'fork',
description "It's a fork.";

[ Initialise;

    location = garden;
    lookmode = 2;
    print "^^This is a simple game for bug-testing.^^^";
    Banner(); return 2;
];

Include "Grammar";

Additional information :

The interpreter will crash.

imported from: [Mantis 2046] "undo" after replay input crashes Glulx interpreter
  • status: Closed
  • resolution: Resolved
  • resolved: 2022-04-07T05:02:32+10:00
  • imported: 2022/01/10
curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by DavidG :


>recording on
[Command recording on.]

>take feather
Taken.

>recording off
[Command recording off.]

>replay
[Replaying commands.]

>take feather
You already have that.

>recording off
[Command replay complete.]

>undo
Beautiful Garden
[Previous turn undone.]

>
--------------------------------------------------------------------------------
Glulxe fatal error: Reference to nonexistent Glk object.

Hit any key to exit.

curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by DavidG :
Cross reported to https://gitlab.com/DavidGriffith/inform6lib/issues/55

curiousdannii-testing commented 2 years ago

557058:4c095ffd-6d6f-47ce-9e73-77c613347b86:

Comment by DavidG :
Fixed in https://gitlab.com/DavidGriffith/inform6lib/commit/74df3809e58fef5f967142d12e3f7573dbfee6b2