Inform - Support - Patches

About Patches  

Compiler  
Library  

DM4 Errata  

Issue C62116

Certain abbreviations can crash compiler
Submitted by: Allen Noe     Appeared in: Compiler 6.21 or before     Fixed in: Compiler 6.30
Problem

Any Abbreviate directive containing a substring of "<unknown attribute>" will cause try_abbreviations_from() in text.c to attempt to modify a string literal passed down from symbols.c line 305. ISO C99 states at an attempt to modify a string literal causes "undefined behavior".

Modifying string literals was legal under traditional K&R C; however modern, standard-compliant compilers (such as GCC) will tell modern operating systems (such as Linux) to mark the memory segment containing these strings as read-only. An attempt to write to a string literal in this situation will cause a segmentation violation, also known as a "crash".

Note that this bug does not cause a crash in all combinations of operating system and compiler.

Solution

There appear to be at least two ways to fix this problem. One is to compile inform with either the -traditional or -fwritable-strings options of GCC; the other is to put the literal string into an array. This patch implements the latter approach:

  --- symbols.c.orig      Fri Oct 15 01:47:19 1999
  +++ symbols.c   Tue Dec 11 17:22:27 2001
  @@ -294,6 +294,7 @@

   extern void write_the_identifier_names(void)
   {   int i, j, k, t, null_value; char idname_string[256];
  +    static char unknown_attribute[20] = "<unknown attribute>";

       for (i=0; i<no_individual_properties; i++)
           individual_name_strings[i] = 0;
  @@ -302,7 +303,7 @@

       veneer_mode = TRUE;

  -    null_value = compile_string("<unknown attribute>", FALSE, FALSE);
  +    null_value = compile_string(unknown_attribute, FALSE, FALSE);
       for (i=0; i<48; i++) attribute_name_strings[i] = null_value;

       for (i=0; i<no_symbols; i++)


Last updated 17 April 2013. This web site has not been fully supported since April 2008. Information may be out of date. This page was originally managed by Roger Firth.