Subject: compiler madness
To: None <port-sparc64@netbsd.org>
From: Volker Stolz <stolz@hyperion.informatik.rwth-aachen.de>
List: port-sparc64
Date: 03/28/2002 17:42:09
Maybe this is useful for tracking some compiler bug or whatever:
The INN port segfaults on startup in a very interesting way.
innd/timer.c uses three tables to track usage. Those are
declared as follows (there's no need to omit the 'static', in fact,
adding 'static' fixes the problem):

unsigned start[TMR_MAX];
unsigned cumulative[TMR_MAX];
unsigned count[TMR_MAX];

The following loop will fail on writing to start[0]:

for (i = 0; i < TMR_MAX; i++) {
        count[i] = start[i] = cumulative[i] = 0;
    }

In gdb, 'count' & 'cumulative' show up as empty memory,
only 'start' contains (seemingly) random garbage. There seems to
be something wrong when the program tries to write to 'start',
although there's nothing particular to see in gdb.

Making these three arrays 'static' fixes the problem, no more
segfaults (disabling optimization doesn't change the results,
either). I'm running James' 20020328-snapshot, although I saw the
segfault even before the update, but I didn't investigate.

Can somebody explain this? Unluckily, I cannot reproduce this by
a small sample program :-/ Should I file a PR?
-- 
Wonderful \hbox (0.80312pt too nice) in paragraph at lines 16--18
Volker Stolz * stolz@i2.informatik.rwth-aachen.de
Please use PGP or S/MIME for correspondence!