RedHat Linux 6.0 warning: stack corruption with "g++ -O2" and "pow()"

From: Matthew D. Langston (langston@SLAC.stanford.edu)
Date: Tue Jun 29 1999 - 18:24:02 MEST


I have found a bug in egcs 1.1.2 in which bad assembly code can be
generated when optimizations of "-O2" and higher are used with calls to
"pow()" from glibc 2.1.

This bug will mainly affect Linux users, and will specifically affect
RedHat Linux 6.0 users.

This isn't a ROOT bug - it is an egcs (i.e. g++) bug.  However, the
reason I am posting it to roottalk is that I came across it while using
ROOT, and ROOT uses "pow()" internally in a few places.  It can be a
subtle bug, so I wanted to make you aware of it.

I reported this bug to the egcs developers, who, to their credit,
promptly fixed it in CVS within hours after I reported it.

I don't mean to sound alarming.  This bug is just something you should
be aware of.  RedHat Liunx 6.0 is beginning to propagate itself through
the community, so others will undoubtedly experience this bug too.  It
took me several days to track down this bug, so I hope this e-mail may
help others who come across it.

In summary:

If you use one of the ROOT binaries which you downloaded from
http://root.cern.ch/, then there is no problem.  All of these binaries
were compiled with "-O", and this particular egcs bug only occurs with
"-O2" and higher.

If you compile your own ROOT binaries from source using the ROOT
Makefiles, then you are also OK, since all of the Makefiles use
"-O".

If you compile your own ROOT binaries from source using "g++ -O2" on a
system where g++ is from egcs 1.1.2, then you won't necessarily have any
problems, but you might.  This warning also applies, of course, to any
code you've written yourself which is compiled with "g++ -O2" and uses
"pow()" (i.e. shared libraries you may have written to use with ROOT).

--
Matthew D. Langston
SLD, Stanford Linear Accelerator Center
langston@SLAC.Stanford.EDU



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:35 MET