[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#333766: libc6: SIGBUS in libm on hppa breaks qt-x11-free

[Ccing debian-hppa@l.d.o, because there is people who know hppa assembly there]


Steve Langasek a écrit :
Package: libc6
Version: 2.3.5-6.0.1
Severity: serious
Justification: this is the bug that broke the toolkit that held up the \
  C++ transition that ruined the port that HP built

Hey Goto-san,

There is a bug in libm that results in unaligned access on hppa when calling
feholdexcept() or fegetenv().  Trivially reproducible with the following

#include <fenv.h>

int main() {
        int foo;
        fenv_t fenv;

I'm afraid I can't offer a patch for this since I don't speak hppa assembly,
but the issue (and the fix) should be pretty obvious: fenv_t is a struct
composed of unsigned ints, so only 32-bit alignment is guaranteed;
feholdexcept() and fegetenv() populate the 8-int struct using four calls,
which means each call acts on 64 bits...  and SIGBUS.

When looking at the assembly code generated with gcc-3.3/gcc-3.4 and with gcc-4.0, I see some differences:

source code:
  __asm__ (
           "fstd,ma %%fr0,8(%1)\n"
           "fstd,ma %%fr1,8(%1)\n"
           "fstd,ma %%fr2,8(%1)\n"
           "fstd,ma %%fr3,8(%1)\n"
           : "=m" (*_regs), "+r" (_regs));

gcc-3.3/gcc-3.4 (code working correctly):
   10624:       2e 91 10 23     fldd,ma -8(,r20),fpe6
   10628:       2e 91 10 22     fldd,ma -8(,r20),fpe4
   1062c:       2e 91 10 21     fldd,ma -8(,r20),fpe2
   10630:       2e 91 30 20     fldd,mb -8(,r20),fr0

gcc-4.0 (SIGBUS):
   1062c:       2f 91 10 23     fldd,ma -8(,ret0),fpe6
   10630:       2f 91 10 22     fldd,ma -8(,ret0),fpe4
   10634:       2f 91 10 21     fldd,ma -8(,ret0),fpe2
   10638:       2f 91 30 20     fldd,mb -8(,ret0),fr0

I also don't speak hppa assembly, but it is obvious that the code does not use the same registers. Maybe the bug is in gcc which generates wrong code? At least the same source code built with gcc-3.3 and gcc-3.4 is working correctly.

Previous versions of gcc-4.0 where known to generate wrong code in the glibc, causing fakeroot to stop working. Another gcc bug?


  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net

Reply to: