data corruption: gcc/powerpc implicit use of FP registers

Till Straumann strauman at slac.stanford.edu
Tue Nov 1 21:31:58 UTC 2005


It seems that some versions of gcc (gcc-3.2, gcc-3.4 but not gcc-4.0.2)
implicitely use floating-point registers, at least for 64bit data
moves. This means that an integer-only task doing things like

   struct x { unsigned a,b; };

   void cpx(struct x *p1, struct x *p2)
   {
     *p1 = *p2;
   }

may suffer from corruption by a FP task being scheduled while the
copy is in process.

There is an old thread (10/2002) on the gcc mailing list discussing
a '-no-implicit-fp' option which, however, was never adopted.

Joel had posted that RTEMS/PPC [as a workaround] implicitely treats
all tasks as FP but I believe this is not true (anymore?).

   *Hence, I believe that data corruption
    is lingering out there*.

It is quite unlikely but not impossible. (task switch to
a FP task must happen while integer-only task is using
the FPU [e.g., interrupt during 64-bit move scheduling
FP task]).

-- Till

PS:
I am not affected here since I enabled 'lazy FP switching' with
special patches to setjmp/longjmp and vfprintf and I disable
the FPU for integer-only tasks to catch these problems...



More information about the users mailing list