2005-05-01

talarubi: (what is hope?)
2005-05-01 02:03 pm

AGH AAGH EVIL CODE

Brownie points to anyone who can spot the dire problem:
typedef AsmParserRec* AsmParser;

int NewAsmParser(AsmParser* Parser, char* Input, int Length) {
  // Note: New() is like Pascal New, e.g. it modifies the supplied pointer.
  //   Hence pass-by-reference.
  if(New(Parser, sizeof(AsmParser))) {
    (*Parser)->Input     = Input;
    (*Parser)->Length    = Length;
    (*Parser)->Line      = 1;
    (*Parser)->Column    = 1;
  ...
}
Hey, I know. Almost nobody ever comments in here, so reply with the right guess, and I'll get you an LJ icon or something? 8)

This otherwise innocous snippet took up my morning bluescreening Win9x!! If I didn't have access to a box with a real OS I don't know what I'd be doing right now... But fortunately, GDB under WinXP correctly traps the problem even though it runs "fine" from the prompt. Code is happy now.

Is it surprising that the dumbest goofs are the most devastating? Eesh. x..X