curiousdannii-testing / inform7-imported-bugs

0 stars 0 forks source link

[I7-1964] [Mantis 2000] double free or corruption bug with undeclared variable #120

Closed curiousdannii-testing closed 2 years ago

curiousdannii-testing commented 2 years ago

Reported by : DavidG

Description :

While tinkering with Possessive() in english.h in the Inform6 Library (http://www.intfiction.org/forum/viewtopic.php?f=7&t=21349), I wound up getting this error when compiling a simple test game:


$ inform +./ wave.inf
Inform 6.34 for Unix (5th March 2016)
"./English.h", line 643: Error: No such constant as "obj2"

      • Error in `inform': double free or corruption (!prev): 0x0000000001408d10 ***
        Aborted

Here's the modified english.h:


[ Possessive obj caps owned; ! "owned" is a new parameter
if (obj == player) {
if (player provides narrative_voice) switch(player.narrative_voice)

{ 1: if (caps) print "M"; else print "m"; print "y"; return; 2: ! Do nothing. 3: CDefart(player); print "'s"; return; default: RunTimeError(16, player.narrative_voice); }

if (caps) print "Y"; else print "y";
print "our"; return;
}

! This is the new block of code
if (owned)

{ CDefart(obj2); ! CDefart(obj); print "'s"; return; }

if (caps) print "H"; else print "h";
if (obj has male)

{ print "is"; return; }

if (obj has female)

{ print "er"; return; }

if (caps) print "I"; else

{ print "i"; print "ts"; return; }

];

The compiler correctly complained about "obj2" being undeclared, but somehow the precise way I did this caused the compiler to choke. Yes, it would abort anyway, but this is abnormal, right?

Now here's a test game:

Steps to reproduce :

Constant Story "ROCKS";
Constant Headline "^An Interactive Bug Reproduction^";
Constant DEBUG;

Include "parser.h";
Include "verblib.h";

Object Start_Room "Somewhere"
  with description "You're not sure where you are.",
  has light;

Class Rock
    with name "rock" "rocks//p",
    short_name "rock",
    plural "rocks";

Rock ->;
Rock ->;
Rock ->;
Rock ->;

[ Initialise;
  location = Start_Room;
  "It is time to do some bugfixing...";
];

Include "grammar.h";

Additional information :

Originally reported at http://www.intfiction.org/forum/viewtopic.php?f=7&t=21398 due to DNS problems with the inform7.com domain.

imported from: [Mantis 2000] double free or corruption bug with undeclared variable
  • status: Closed
  • resolution: Resolved
  • resolved: 2022-04-07T05:02:13+10:00
  • imported: 2022/01/10
curiousdannii-testing commented 2 years ago

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

Comment by zarf :
I've tried to reproduce this, but no luck.

I was testing on Linux (with "#define LINUX" in the header), using your inform6lib master branch with that substitution for Possessive() in English.h, and that test source file. Also tested on MacOS with libgmalloc. The compiler reliably says "No such constant as "obj2"" but I don't see any memory errors.

curiousdannii-testing commented 2 years ago

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

Comment by zarf :
Are you using the latest Inform code? This looks a lot like http://inform7.com/mantis/view.php?id=1934 .

curiousdannii-testing commented 2 years ago

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

Comment by DavidG :
I'm using https://github.com/DavidKinder/Inform6/tree/5af7cef4fa8c45334ed1ef7f3d808867e69535a2
which is the one I'm pulling in from https://github.com/DavidGriffith/inform6unix. Would you please clone that and try again? Is this is fixed in the absolute latest code, it would be nice to see what happened and hopefully head off unintended consequences.

curiousdannii-testing commented 2 years ago

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

Comment by DavidG :
I did a bisection of the source and I see that https://github.com/DavidKinder/Inform6/tree/25a93cfd5400600e4b6f1192cf00dfe66b04b521 (Fix for Mantis #1934: Don't fclose() files more than once) fixes this one (#2000). I think this issue can be closed.

curiousdannii-testing commented 2 years ago

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

Comment by DavidG :
Oooo!!! 2000 issues! What a milestone!