Inform - Support - Patches

About Patches  

Compiler  
Library  

DM4 Errata  

Issue C63013     [previous patch]

Complex 'if' crashes compiler
Submitted by: Roger Firth     Appeared in: Compiler 6.30 or before     Fixed in: Compiler 6.31
Problem

This code causes a compiler crash, which doesn't happen if the number of tests is reduced to 27.

  if (x ==  1 or  2 or  3 or  4 or  5 or  6 or  7 or  8 or  9
        or 10 or 11 or 12 or 13 or 14 or 15 or 16 or 17 or 18
        or 19 or 20 or 21 or 22 or 23 or 24 or 25 or 26 or 27 or 28) ...
Solution (by David Kinder)

I tracked it down to corruption of the "emitter_markers" buffer that's allocated in expressp.c:

  * Declared as an int pointer in the middle of the file ...
  static int *emitter_markers;
  * ... but allocated as a char buffer at the end!
    emitter_markers = my_calloc(sizeof(char), MAX_EXPRESSION_NODES,
        "emitter markers");

Since on Win32 int is four times bigger than char, any use of emitter_markers[25] or higher bounces off the end of memory, leading to random corruption. Apply this patch:

--- cvs/compiler/expressp.c 2004-04-28 23:59:00.625000000 +0100
+++ patched/expressp.c 2004-08-15 11:04:08.140625000 +0100
@@ -1792,7 +1792,7 @@
 extern void expressp_allocate_arrays(void)
 {   ET = my_calloc(sizeof(expression_tree_node), MAX_EXPRESSION_NODES,
         "expression parse trees");
-    emitter_markers = my_calloc(sizeof(char), MAX_EXPRESSION_NODES,
+    emitter_markers = my_calloc(sizeof(int), MAX_EXPRESSION_NODES,
         "emitter markers");
     emitter_stack = my_calloc(sizeof(assembly_operand), MAX_EXPRESSION_NODES,
         "emitter stack");


Last updated 17 April 2013. This site is no longer supported; information may be out of date.
Maintained as a historical archive by the Interactive Fiction Technology Foundation. Copyright 1993-2018 IFTF, CC-BY-SA unless otherwise noted.
This page was originally managed by Roger Firth.