dworkin / dgd

Dworkin's Game Driver, an object-oriented database management system originally used to run MUDs.
https://www.dworkin.nl/dgd/
GNU Affero General Public License v3.0
103 stars 31 forks source link

Crashed driver while testing label and goto. #92

Open knubo opened 3 weeks ago

knubo commented 3 weeks ago

I wrote (more or less this) in a function:

void crash() {

oups:

/ Some code /

goto oups; }

The driver crashed while trying to compile this. I was looking into do a break to label from a double nested for loop, but I could not forward reference my label so I just for compile time tested to put it before the goto statement.

This was on DGD 1.7.3

dworkin commented 3 weeks ago

I can't reproduce a crash with this code.

By the way, I don't consider goto to oficially be part of LPC -- I added it to as a kind of underground feature to simplify machine-producing LPC code. As such, it does have some similarly-undocumented limitations.

knubo commented 3 weeks ago

I think this is close to the code I tried to compile:

object query_tree_near(object player) {
  int *loc;
  object tree;
  int col,row;
  int x,y, found;

  loc = locations[player];

 jumphere:

  for(col=-1;col < 1 && !found; col++) {
    for(row=-1; row < 1 && !found; row++) {

      x = loc[0] + col;
      y = loc[1] + row;

      if(content[y*(content_size_x+1)+x] == '*') {
    found = 1;

    goto jumphere;
    break;
      }
    }
  }

 jumphere:
  if(!found) {
    return 0;
  }

  tree = clone_object("/d/Limitless/obj/tmp_tree");
  tree->set_chop_location(copy(locations[player]));

  return tree;
}

I probably tried to add and remove the labels and compile it a couple of times.

dworkin commented 3 weeks ago

Alas, that still doesn't crash.