This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: Avoid calls to realloc for nvptx
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Thomas Schwinge <thomas at codesourcery dot com>
- Cc: Bernd Schmidt <bernds at codesourcery dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>, gfortran <fortran at gcc dot gnu dot org>, FX <fxcoudert at gmail dot com>
- Date: Wed, 22 Oct 2014 11:47:06 +0200
- Subject: Re: Avoid calls to realloc for nvptx
- Authentication-results: sourceware.org; auth=none
- References: <5446D752 dot 9010405 at codesourcery dot com> <C6BA9188-026E-46B4-9BA4-DA9856CB35C8 at gmail dot com> <20141022080448 dot GG10376 at tucnak dot redhat dot com> <874muwjxaf dot fsf at kepler dot schwinge dot homeip dot net>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Oct 22, 2014 at 10:58:32AM +0200, Thomas Schwinge wrote:
> So, something in spirit of what has been implemented in
> gcc/config/i386/gmm_malloc.h.
Yeah, though don't take that literally, gmm_malloc.h e.g. isn't very secure,
_mm_malloc (-16384, 32768);
might very well result in heap corruption already by the inline function, or
by the caller, even when the malloc inside
of it actually allocated just 16384 bytes.
There should be:
if (size >= -align)
{
errno = ENOMEM;
return (void *) 0;
}
before the malloc call.
Jakub