Bug 50378 - MALLOC_CHECK_ glibc detects free() invalid pointer in compiler
Summary: MALLOC_CHECK_ glibc detects free() invalid pointer in compiler
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.6.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-13 09:02 UTC by Vittorio Zecca
Modified: 2011-09-14 20:13 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
just compile it (212 bytes, text/plain)
2011-09-13 09:02 UTC, Vittorio Zecca
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vittorio Zecca 2011-09-13 09:02:47 UTC
Created attachment 25257 [details]
just compile it

MALLOC_CHECK_ glibc detects free() invalid pointer in compiler
Comment 1 Tobias Burnus 2011-09-13 09:16:35 UTC
Works for me with 4.7 (also in valgrind); with 4.6.1 20110801 [gcc-4_6-branch revision 177033] I get an ICE (abort) and valgrind shows:

==5778== Invalid read of size 4
==5778==    at 0x5FC8C10: __gmpz_clear (in /usr/lib64/libgmp.so.10.0.1)

However, using 4.7.0 20110908 (experimental) [trunk revision 178693] I do not get an ICE/valgrind warning - hence it might be fixed.
Comment 2 Mikael Morin 2011-09-13 09:39:14 UTC
PR 50050 ?
Comment 3 kargls 2011-09-13 15:56:33 UTC
(In reply to comment #2)
> PR 50050 ?

Yes, your patch(es) for PR 50050 appear to have fixed
this issue.  I had an older 4.5.4 that gave an error,
but a newly built 4.5.4 works as expected.

Vittorio, can you update your 4.6.1 to a newer
version and retry your test case?
Comment 4 Vittorio Zecca 2011-09-13 20:08:33 UTC
I thought I had the latest version of gfortran...
Where can I find the latest one, with sources?
Comment 5 Steve Kargl 2011-09-13 20:14:33 UTC
On Tue, Sep 13, 2011 at 08:08:33PM +0000, zeccav at gmail dot com wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50378
> 
> --- Comment #4 from Vittorio Zecca <zeccav at gmail dot com> 2011-09-13 20:08:33 UTC ---
> I thought I had the latest version of gfortran...
> Where can I find the latest one, with sources?
> 

What does gfortran -v report?  Your code causes not problem for 

gcc version 4.5.4 20110913 (prerelease) (GCC) 
gcc version 4.6.1 20110606 (prerelease) (GCC) 
gcc version 4.7.0 20110908 (experimental) (GCC) 

In looking at the date of my 4.6.1, I may have messed
up my testing becaue Mikael patch is after that date.
Time to rebuild and retest.
Comment 6 Vittorio Zecca 2011-09-13 20:19:56 UTC
I have gfortran 4.6.1
I am downloading gcc-4.7.tar.xz from gfortran.org right now.
Tomorrow I'll check it, it is night here.
Comment 7 Tobias Burnus 2011-09-13 20:31:26 UTC
(In reply to comment #4)
> I thought I had the latest version of gfortran...
> Where can I find the latest one, with sources?

While 4.6.1 (released 2011-08-17) is the latest stable release, you should use the latest branch ("gcc-4_6-branch") or the development version (trunk, 4.7). They are available via Subversion (http://gcc.gnu.org/svn.html), GIT (http://gcc.gnu.org/git/?p=gcc.git) and as regular (weekly?) source snapshots.

Additionally, there exists also binary builds. See http://gcc.gnu.org/wiki/GFortranBinaries for a link to the binaries and (at the bottom) some pieces of information/links for building GCC from source.

It makes sense to report bugs against the current gcc-4_6-branch or 4.7 as those contain all the existing fixes, which will be part in the next release. Also Linux distributions tend to base their GCC packages on the release branches and not on the releases from the release branch.
Comment 8 Vittorio Zecca 2011-09-14 08:23:39 UTC
gfortran 4.7.0 fixes this one.
However, sometimes I get the following:

/home/vitti/gcc-4.7/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/f951: symbol lookup error: /home/vitti/gcc-4.7/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.7.0/f951: undefined symbol: mpfr_get_z_exp

Never got this one, I have mpfr-3.0.0-4
How can I fix it?
Comment 9 Tobias Burnus 2011-09-14 08:50:04 UTC
(In reply to comment #8)
> x86_64-unknown-linux-gnu/4.7.0/f951:
> symbol lookup error:
> undefined symbol: mpfr_get_z_exp
> 
> Never got this one, I have mpfr-3.0.0-4

See http://www.mpfr.org/mpfr-3.0.0/#changes and http://www.mpfr.org/mpfr-3.0.1/mpfr.html#Changed-Functions

"mpfr_get_z_exp changed in MPFR 3.0 [...] this function has been renamed to mpfr_get_z_2exp in MPFR 3.0" and "mpfr_get_z_exp is still available via a macro in mpfr.h".

Seemingly, you have a f951 which has been compiled with MPFR 2.x but you run it with MPFR 3. In that case, the macro does not help.

gfortran calls this function for real-to-integer conversions, which seems to be the only use.
Comment 10 Vittorio Zecca 2011-09-14 20:01:17 UTC
gfortran 4.7.0 has been compiled with the old mpfr 2.4.2, I just downloaded it, this one will probably work. 
Anyway gfortran 4.7.0 does not give free() errors.
Comment 11 kargls 2011-09-14 20:13:17 UTC
(In reply to comment #10)
> gfortran 4.7.0 has been compiled with the old mpfr 2.4.2, I just downloaded it,
> this one will probably work. 
> Anyway gfortran 4.7.0 does not give free() errors.

Thanks for the bug report and confirming that the issue
is fixed.