GFORTRAN_CONVERT_UNIT not working for me in some situations
Shane Hart
shart6@utk.edu
Thu Sep 27 19:50:00 GMT 2012
I have a program that reads and writes several large files in big endian format
on several predefined file units. Since I'm using a little-endian system
(x86_64) there is code some of the wrapper utilities that set
GFORTRAN_CONVERT_UNIT to big endian for these units. Relevent script fragment
below:
# gfortran compiler
export GFORTRAN_CONVERT_UNIT='native;big_endian:60-70,80-89'
However, whenever any Fortran program is started with this set, it causes:
malloc.c:2368: sysmalloc: Assertion `(old_top == (((mbinptr) (((char *)
&((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd))))
&& old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)
((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 *
(sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size
& 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
Aborted
This has been tested on (and fails):
Arch Linux (GCC 4.7.1) - 32 bit
Arch Linux (GCC 4.7.2) - 32 bit
Arch Linux (GCC 4.7.1) - 64 bit
Ubuntu 12.04 (GCC 4.6.3) - 64 bit
Linux Mint 13 (GCC 4.6.3) - 32 bit
Ubuntu 12.10 Beta 1 (GCC 4.7.2) - 32 bit
OpenSUSE 12.2 (GCC 4.7.1) - 32 bit
However, the program runs successfully on:
Fedora 17 (GCC 4.7.0) - 64 bit
Fedora 17 (GCC 4.7.2) - 64 bit
Fedora 18 Alpha (GCC 4.7.2) - 32 bit
To further test I wrote a simple program that writes "Hello World!" to the
screen and ran it like thus:
[shane@shane-laptop ~/temp/testgfortran]$ gfortran --version
GNU Fortran (GCC) 4.7.1 20120721 (prerelease)
Copyright (C) 2012 Free Software Foundation, Inc.
GNU Fortran comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Fortran
under the terms of the GNU General Public License.
For more information about these matters, see the file named COPYING
[shane@shane-laptop ~/temp/testgfortran]$ cat fake.f90
program fake
print*, 'hello world!'
end program fake
[shane@shane-laptop ~/temp/testgfortran]$ gfortran -o fake fake.f90
[shane@shane-laptop ~/temp/testgfortran]$ ./fake
hello world!
[shane@shane-laptop ~/temp/testgfortran]$
GFORTRAN_CONVERT_UNIT='native;big_endian:88' ./fake
fake: malloc.c:2368: sysmalloc: Assertion `(old_top == (((mbinptr) (((char *)
&((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd))))
&& old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)
((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 *
(sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size
& 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
Aborted
[shane@shane-laptop ~/temp/testgfortran]$
However, this does seem to work on Debian testing.
According to the GNU GFortran manual at:
http://gcc.gnu.org/onlinedocs/gcc-4.7.2/gfortran/GFORTRAN_005fCONVERT_005fUNIT.html
this is the correct way to do this. I can't believe that this is a bug since
it affects so many distributions/versions, so I must be doing something wrong.
Any ideas on how to specify the endianness for certain Fortran units without
changing the source? (convert='big_endian' does seem to work, but right now I
can't change the huge monolithic program).
Thanks for any help,
Shane Hart
More information about the Gcc-help
mailing list