public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/56789] New: Wrong code with contiguous dummy argument
@ 2013-03-30 22:24 tkoenig at gcc dot gnu.org
2013-03-30 22:35 ` [Bug fortran/56789] " tkoenig at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2013-03-30 22:24 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56789
Bug #: 56789
Summary: Wrong code with contiguous dummy argument
Classification: Unclassified
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: tkoenig@gcc.gnu.org
This is from
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41137#c15
ig25@linux-fd1f:~/Krempel/Contig> cat foo.f90
module zero
implicit none
contains
subroutine foo(a)
real, contiguous :: a(:,:)
a(:,:) = 0
end subroutine foo
end module zero
program main
use zero
implicit none
real, dimension(5,5) :: a
a = 1.
call foo(a(1:5:2,1:5:2))
! write (*,'(5F12.5)') a
end program main
ig25@linux-fd1f:~/Krempel/Contig> gfortran foo.f90
ig25@linux-fd1f:~/Krempel/Contig> ./a.out
*** glibc detected *** ./a.out: free(): invalid next size (fast):
0x0000000000629f90 ***
a.out: malloc.c:2451: 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.
Program received signal SIGABRT: Process abort signal.
Backtrace for this error:
[...]
ig25@linux-fd1f:~/Krempel/Contig> valgrind ./a.out
==19631== Memcheck, a memory error detector
==19631== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==19631== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==19631== Command: ./a.out
==19631==
==19631== Invalid write of size 4
==19631== at 0x4007F7: __zero_MOD_foo (in /home/ig25/Krempel/Contig/a.out)
==19631== by 0x4008E8: MAIN__ (in /home/ig25/Krempel/Contig/a.out)
==19631== by 0x40095A: main (in /home/ig25/Krempel/Contig/a.out)
==19631== Address 0x5c38428 is 4 bytes after a block of size 36 alloc'd
==19631== at 0x4C2ABED: malloc (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19631== by 0x4E4C714: _gfortrani_xmalloc (memory.c:38)
==19631== by 0x4EE9B23: _gfortrani_internal_pack_r4 (in_pack_r4.c:79)
==19631== by 0x4008CF: MAIN__ (in /home/ig25/Krempel/Contig/a.out)
==19631== by 0x40095A: main (in /home/ig25/Krempel/Contig/a.out)
==19631==
==19631==
==19631== HEAP SUMMARY:
==19631== in use at exit: 0 bytes in 0 blocks
==19631== total heap usage: 22 allocs, 22 frees, 11,858 bytes allocated
==19631==
==19631== All heap blocks were freed -- no leaks are possible
==19631==
==19631== For counts of detected and suppressed errors, rerun with: -v
==19631== ERROR SUMMARY: 6 errors from 1 contexts (suppressed: 2 from 2)
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/56789] Wrong code with contiguous dummy argument
2013-03-30 22:24 [Bug fortran/56789] New: Wrong code with contiguous dummy argument tkoenig at gcc dot gnu.org
@ 2013-03-30 22:35 ` tkoenig at gcc dot gnu.org
2014-07-10 0:40 ` quantheory at gmail dot com
2014-07-10 0:49 ` quantheory at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: tkoenig at gcc dot gnu.org @ 2013-03-30 22:35 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56789
Thomas Koenig <tkoenig at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu.org
--- Comment #1 from Thomas Koenig <tkoenig at gcc dot gnu.org> 2013-03-30 22:35:51 UTC ---
The problem is that we pack the data, but do
not adjust the descriptor accordingly.
The dump looks like this:
parm.10.dtype = 282;
parm.10.dim[0].lbound = 1;
parm.10.dim[0].ubound = 3;
parm.10.dim[0].stride = 2;
parm.10.dim[1].lbound = 1;
parm.10.dim[1].ubound = 3;
parm.10.dim[1].stride = 10;
parm.10.data = (void *) &a[0];
parm.10.offset = 0;
origptr.11 = parm.10.data;
D.1929 = _gfortran_internal_pack (&parm.10);
parm.10.data = D.1929;
foo (&parm.10);
and it should look like this:
parm.12.dim[0].lbound = 1;
parm.12.dim[0].ubound = 3;
parm.12.dim[0].stride = 1;
parm.12.dim[1].lbound = 1;
parm.12.dim[1].ubound = 3;
parm.12.dim[1].stride = 3;
[...]
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/56789] Wrong code with contiguous dummy argument
2013-03-30 22:24 [Bug fortran/56789] New: Wrong code with contiguous dummy argument tkoenig at gcc dot gnu.org
2013-03-30 22:35 ` [Bug fortran/56789] " tkoenig at gcc dot gnu.org
@ 2014-07-10 0:40 ` quantheory at gmail dot com
2014-07-10 0:49 ` quantheory at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: quantheory at gmail dot com @ 2014-07-10 0:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56789
Sean Santos <quantheory at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |quantheory at gmail dot com
--- Comment #3 from Sean Santos <quantheory at gmail dot com> ---
I just want to note that I've encountered this in the wild using GCC 4.8. As
you would guess, the strides are not necessary; any argument that has to be
packed will cause a segfault when freeing the temporary, such as:
call foo(a(:4,:))
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug fortran/56789] Wrong code with contiguous dummy argument
2013-03-30 22:24 [Bug fortran/56789] New: Wrong code with contiguous dummy argument tkoenig at gcc dot gnu.org
2013-03-30 22:35 ` [Bug fortran/56789] " tkoenig at gcc dot gnu.org
2014-07-10 0:40 ` quantheory at gmail dot com
@ 2014-07-10 0:49 ` quantheory at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: quantheory at gmail dot com @ 2014-07-10 0:49 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56789
--- Comment #4 from Sean Santos <quantheory at gmail dot com> ---
Oops, I mean a free() error as in comment 0, not a segfault.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-07-10 0:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-30 22:24 [Bug fortran/56789] New: Wrong code with contiguous dummy argument tkoenig at gcc dot gnu.org
2013-03-30 22:35 ` [Bug fortran/56789] " tkoenig at gcc dot gnu.org
2014-07-10 0:40 ` quantheory at gmail dot com
2014-07-10 0:49 ` quantheory at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).