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. 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:
About Patches
Issue C62116
Certain abbreviations can crash compiler
Submitted by: Allen Noe
Appeared in: Compiler 6.21 or before
Fixed in: Compiler 6.30
Problem
Solution
--- 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 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.