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

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



Hi,

Stephen Gran a écrit :
This one time, at band camp, Steve Langasek said:

On Thu, Oct 13, 2005 at 07:26:43PM +0200, Aurelien Jarno wrote:


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

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.

No, it isn't:

glibc (2.3.5-6.0.1) unstable; urgency=low

 * On hppa, build using gcc-3.4.

-- Matthias Klose <doko@debian.org>  Sat, 17 Sep 2005 10:55:42 +0000

This is the version of libc6 running on the buildd and in paer's unstable
chroot where I reproduced the error.  So glibc is known to have problems on
hppa when built with gcc-4.0, but this doesn't appear to be one of them.


I think you are misunderstanding him, Steve, or I am misunderstanding
the whole thing (which is not unlikely).  I think Aurelian is saying
that the same source code that you supplied builds and runs fine with
gcc-3.4, but not with gcc-4.0:

sgran@paer:~$ dchroot sid
Executing shell in chroot: /org/paer.debian.org/chroot/sid
sgran@paer:~$ cat test.c
#include <fenv.h>

int main() {
        int foo;
        fenv_t fenv;
        feholdexcept(&fenv);
}
sgran@paer:~$ gcc-3.4 -lm test.c -o test.3.4
sgran@paer:~$ gcc-4.0 -lm test.c -o test.4
sgran@paer:~$ ./test.3.4
sgran@paer:~$ ./test.4
Bus error

This certainly smells more like a compiler bug than anything.  The same
library and the same header files, 2 different compiler versions, 2
results.

Well we've discussed a bit of that on IRC with Steve, I think we have two problems (maybe linked):
- gcc-3.4 and gcc-4.0 changed the way they align the code.
  Have a look at your test.c file. There is nothing in it, and moreover
  gdb show the problem appears in libm, which has been compiled with
  gcc-3.4.
- gcc-4.0 generates wrong code
  For that see my attached file. It's the file from the glibc, with the
  code from Steve pasted at the end. It works with gcc-3.4, but fails
  with gcc-4.0.

Bye,
Aurelien

--
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net
/* Store current floating-point environment and clear exceptions.
   Copyright (C) 2000 Free Software Foundation, Inc.
   This file is part of the GNU C Library.
   Contributed by David Huggins-Daines <dhd@debian.org>, 2000

   The GNU C Library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
   License as published by the Free Software Foundation; either
   version 2.1 of the License, or (at your option) any later version.

   The GNU C Library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Lesser General Public License for more details.

   You should have received a copy of the GNU Lesser General Public
   License along with the GNU C Library; if not, write to the Free
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   02111-1307 USA.  */

#include <fenv.h>
#include <string.h>

int
feholdexcept (fenv_t *envp)
{
  fenv_t clear;
  fenv_t * _regs = envp;

  /* Store the environment.  */
  __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));
  memcpy (&clear, envp, sizeof (clear));

  /* Now clear all exceptions.  */
  clear.__status_word &= ~(FE_ALL_EXCEPT << 27);
  memset (clear.__exception, 0, sizeof (clear.__exception));

  /* And set all exceptions to non-stop.  */
  clear.__status_word &= ~FE_ALL_EXCEPT;

  /* Load the new environment. */
  _regs = &clear;
  __asm__ (
	   "fldd,ma 8(%0),%%fr0\n"
	   "fldd,ma 8(%0),%%fr1\n"
	   "fldd,ma 8(%0),%%fr2\n"
	   "fldd,ma 8(%0),%%fr3\n"
	   : : "r" (_regs));

  return 0;
}

int main() {
  int foo;
  fenv_t fenv;
  feholdexcept(&fenv);
}

Reply to: