[Bug fortran/39571] Compiler crash with GNU MP: Cannot reallocate memory

2009-03-30 Thread aran at 100acres dot us


--- Comment #11 from aran at 100acres dot us  2009-03-30 16:51 ---
(In reply to comment #9)

My mistake, I printed the operands to mpz_pow_ui and got

gfc_arith_power: op1   = 2
gfc_arith_power: power = 2147483647

When I call mpz_pow_ui from c with these arguments, I get

GNU MP: Cannot reallocate memory (old_size=4 new_size=268435472)

This is obviously not a fortran bug.


-- 

aran at 100acres dot us changed:

   What|Removed |Added

 Status|WAITING |RESOLVED
 Resolution||INVALID


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39571



[Bug fortran/39571] Compiler crash with GNU MP: Cannot reallocate memory

2009-03-28 Thread aran at 100acres dot us


--- Comment #7 from aran at 100acres dot us  2009-03-28 23:19 ---

 NetBSD seems to be using jemalloc. which is the memory allocator
 from FreeBSD.  Perhaps, your memory is defective.
 

Where would this be?  I can't find jemalloc in the fortran directory.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39571



[Bug fortran/39571] Compiler crash with GNU MP: Cannot reallocate memory

2009-03-28 Thread steven at gcc dot gnu dot org


--- Comment #8 from steven at gcc dot gnu dot org  2009-03-28 23:32 ---
*NetBSD* seems to be using jemalloc, i.e. jemalloc is your system's malloc()
and it is the same as FreeBSD where the test case *does* work.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39571



[Bug fortran/39571] Compiler crash with GNU MP: Cannot reallocate memory

2009-03-28 Thread kargl at gcc dot gnu dot org


--- Comment #9 from kargl at gcc dot gnu dot org  2009-03-29 00:14 ---
(In reply to comment #7)
  NetBSD seems to be using jemalloc. which is the memory allocator
  from FreeBSD.  Perhaps, your memory is defective.
  
 
 Where would this be?  I can't find jemalloc in the fortran directory.
 

Steven is correct.  I am talking about malloc, which comes with your
system.  It was written by Jason Evans as in the je of jemalloc.
You can see the source code at www.netbsd.org in src/lib/libc/stdlib.

What happens when you compile the following:

#include stdio.h
#include gmp.h
int main(void) {
unsigned int u = 268435472u;
mpz_t x;
mpz_init(x);
mpz_set_ui(x, 2);
mpz_out_str (stdout, 10, x);
printf( %u\n, u);
mpz_pow_ui (x, x, u);
mpz_clear(x);
return 0;
}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39571



[Bug fortran/39571] Compiler crash with GNU MP: Cannot reallocate memory

2009-03-28 Thread aran at 100acres dot us


--- Comment #10 from aran at 100acres dot us  2009-03-29 00:50 ---
(In reply to comment #9)
 
 What happens when you compile the following:
 
 #include stdio.h
 #include gmp.h
 int main(void) {
 unsigned int u = 268435472u;
 mpz_t x;
 mpz_init(x);
 mpz_set_ui(x, 2);
 mpz_out_str (stdout, 10, x);
 printf( %u\n, u);
 mpz_pow_ui (x, x, u);
 mpz_clear(x);
 return 0;
 }
 

rmme[0]$./a.out 
2 268435472


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39571



[Bug fortran/39571] Compiler crash with GNU MP: Cannot reallocate memory

2009-03-27 Thread steven at gcc dot gnu dot org


--- Comment #1 from steven at gcc dot gnu dot org  2009-03-28 00:51 ---
Which version of GMP are you using?


-- 

steven at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|UNCONFIRMED |WAITING
  GCC build triplet| i386-unknown-  |i386-unknown-netbsdelf5.99.7
   |netbsdelf5.99.7 |
   GCC host triplet| i386-unknown-  |i386-unknown-netbsdelf5.99.7
   |netbsdelf5.99.7 |
 GCC target triplet| i386-unknown-  |i386-unknown-netbsdelf5.99.7
   |netbsdelf5.99.7 |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39571



[Bug fortran/39571] Compiler crash with GNU MP: Cannot reallocate memory

2009-03-27 Thread kargl at gcc dot gnu dot org


--- Comment #4 from kargl at gcc dot gnu dot org  2009-03-28 03:02 ---
(In reply to comment #3)
 I chased this to airth.c line 1054:
 
 mpz_pow_ui (result-value.integer, op1-value.integer, power);
 
 The variable power is 268435472.
 

On FreeBSD I get
REMOVE:kargl[6] gfc4x -o z a.f90
a.f90:2.12:

  print *, 2**huge(0) 
1
Error: Arithmetic overflow at (1)
REMOVE:kargl[7] gfc43 -o z a.f90
a.f90:2.12:

  print *, 2**huge(0) 
   1
Error: Arithmetic overflow at (1)
REMOVE:kargl[8]

REMOVE:kargl[8] gfc4x --version
GNU Fortran (GCC) 4.4.0 20090308 (experimental) [trunk revision 140508]
REMOVE:kargl[9] gfc43 --version
GNU Fortran (GCC) 4.3.3 20081120 (prerelease)

REMOVE:kargl[11] pkg_info | grep gmp
libgmp-4.2.4A free library for arbitrary precision arithmetic
REMOVE:kargl[12] pkg_info | grep mpfr
mpfr-2.4.1  A library for multiple-precision floating-point computation

Do your gmp/mpfr libraries pass their testsuites?  Do you have more
than one version of one of these libraries installed.

The error message indicates that gmp is broken or perhaps NetBSD's
malloc implementation.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39571



[Bug fortran/39571] Compiler crash with GNU MP: Cannot reallocate memory

2009-03-27 Thread aran at 100acres dot us


--- Comment #5 from aran at 100acres dot us  2009-03-28 04:46 ---
gmp-4.2.4 passes all test.  mpfr-2.4.0 pass all except the tsprintf tests where
my version returns 1.899347461279296875e+07 and the test expects
1,899347461279296875e+07 (notice the decimal point is a period instead of a
comma).

Considering that gmp is being told to raise 2 to the 268435472nd power, I don't
think any system's allocator would work.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39571



[Bug fortran/39571] Compiler crash with GNU MP: Cannot reallocate memory

2009-03-27 Thread kargl at gcc dot gnu dot org


--- Comment #6 from kargl at gcc dot gnu dot org  2009-03-28 05:21 ---
(In reply to comment #5)
 
 Considering that gmp is being told to raise 2 to the 268435472nd power, I
 don't think any system's allocator would work.
 

See my first post.  FreeBSD seems to handle it.  But, there is something
wrong on your OS becuase huge(0) isn't 268435472.

REMOVE:kargl[58] cat  b.f90
print*, huge(0)
end
REMOVE:kargl[60] gfc4x -o z b.f90
REMOVE:kargl[61] ./z
  2147483647

NetBSD seems to be using jemalloc. which is the memory allocator
from FreeBSD.  Perhaps, your memory is defective.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39571