Subject: Bug: global var "err"
To: None <port-arm32@NetBSD.ORG>
From: Erik <erikgrnh@xs4all.nl>
List: port-arm32
Date: 09/28/1997 16:06:04
The following program will crash:

======== example start ======
/*
 * $Source: /usr/distrib/1_2_beta/source/usr.bin/pr/RCS/hop.c,v $
 *
 * $Id: hop.c,v 1.5 1997/09/28 00:46:20 root Exp $
 */

int err;

int
main()
{
	err = 123;
	return 0;
}
======== example end ========

It simply declares a global variable called "err" and then assign a
value to it. The way in which the value is assigned is irrelevant.
The type of the variable is also irrelevant.

What is important is the name of the variable. If you change it to,
for example, "beng", the program runs without problems.

I discovered this bug because the "pr" program crashes. Which is a
pain any time you want to print something, as lpr uses pr to format
the output. Debugging and examination of the source showed that the
crash occured the moment a value was assigned to the global FILE
*err. Lots of testing showed that it was the name of the variable
which caused the problem.

If you are interested, I have modified the source of pr (pr.c) and
recompiled it with GNU CC 2.7.2.1p1 to get a working version. Mail me
for a copy.

System used:
RiscPC 703, StrongARM with buggy STM^,
Kernels: sa110-4713, sa110-4740, sa110-4871, sa110-4958
Compilers: GNU CC 1_2_beta and 2.7.2.1p1

---
Erik @ Emmeloord
Csite on Acorn RiscPC running ANT Internet Suite release II.
   Now using the StrongARM 202 MHz processor:
      more than Pentium power (2 to 3 times faster)
      for less than Pentium power (1 Watt, not 20).