public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/15335] New: [gfortran] runtime error  "Attempt to allocate a non-positive amount of memory"
@ 2004-05-07  0:27 Tobias dot Schlueter at physik dot uni-muenchen dot de
  2004-10-07 23:44 ` [Bug fortran/15335] runtime error "Attempt to allocate a negative " tobi at gcc dot gnu dot org
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Tobias dot Schlueter at physik dot uni-muenchen dot de @ 2004-05-07  0:27 UTC (permalink / raw)
  To: gcc-bugs

This reduced testcase exhibits a problem in memory allocation for temporaries:
  program Driver
    real :: a(4,4)
    call factor
contains
    subroutine Factor
      real :: A(4, 4), B(4), lu(4,4)
      integer:: p(4)
      do M = 1, 4
          LU(P(I), M) = Reduce (LU(P(I), M), LU(P(I), 1: M - 1), LU(P(1: M - 1), M))
      end do

      return
    end subroutine Factor  
    function Reduce (A, Row, Col)
      real :: A, Row(:), Col(:)
      reduce = 0
    end function Reduce
  end program Driver
[tobi@marktplatz meissner]$ gfortran reduced.f90
[tobi@marktplatz meissner]$ ./a.out
Fortran runtime error: Attempt to allocate a non-positive amount of memory.
[tobi@marktplatz meissner]$

After removing either the loop in factor or the declaration in main the program
yields a segfault instead, so this is a out-of-bound memory access. Valgrind
confirms this:
[tobi@marktplatz meissner]$ valgrind ./a.out
==1649== Memcheck, a.k.a. Valgrind, a memory error detector for x86-linux.
==1649== Copyright (C) 2002-2003, and GNU GPL'd, by Julian Seward.
==1649== Using valgrind-2.0.0, a program supervision framework for x86-linux.
==1649== Copyright (C) 2000-2003, and GNU GPL'd, by Julian Seward.
==1649== Estimated CPU clock rate is 799 MHz
==1649== For more details, rerun with: -v
==1649==
==1649== Use of uninitialised value of size 4
==1649==    at 0x804853D: factor.1 (in /home/tobi/src/tests/meissner/a.out)
==1649==    by 0x804874F: MAIN__ (in /home/tobi/src/tests/meissner/a.out)
==1649==    by 0x8048782: main (in /home/tobi/src/tests/meissner/a.out)
==1649==    by 0x24F3F1: __libc_start_main (in /lib/libc-2.3.3.so)
==1649==
==1649== Invalid read of size 4
==1649==    at 0x804853D: factor.1 (in /home/tobi/src/tests/meissner/a.out)
==1649==    by 0x804874F: MAIN__ (in /home/tobi/src/tests/meissner/a.out)
==1649==    by 0x8048782: main (in /home/tobi/src/tests/meissner/a.out)
==1649==    by 0x24F3F1: __libc_start_main (in /lib/libc-2.3.3.so)
==1649==    Address 0x5B73AC is not stack'd, malloc'd or free'd
Fortran runtime error: Attempt to allocate a non-positive amount of memory.
==1649==
==1649== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
==1649== malloc/free: in use at exit: 0 bytes in 0 blocks.
==1649== malloc/free: 4 allocs, 4 frees, 16712 bytes allocated.
==1649== For a detailed leak analysis,  rerun with: --leak-check=yes
==1649== For counts of detected errors, rerun with: -v
[tobi@marktplatz meissner]$

-- 
           Summary: [gfortran] runtime error  "Attempt to allocate a non-
                    positive amount of memory"
           Product: gcc
           Version: tree-ssa
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Tobias dot Schlueter at physik dot uni-muenchen dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux
  GCC host triplet: i686-pc-linux
GCC target triplet: i686-pc-linux


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


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2006-03-02  9:37 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-15335-7283@http.gcc.gnu.org/bugzilla/>
2006-01-09 23:55 ` [Bug fortran/15335] runtime error "Attempt to allocate a negative amount of memory" pinskia at gcc dot gnu dot org
2006-01-10  0:10 ` tobi at gcc dot gnu dot org
2006-03-01 16:30 ` paul dot richard dot thomas at cea dot fr
2006-03-01 16:37 ` tobi at gcc dot gnu dot org
2006-03-01 16:39 ` tobi at gcc dot gnu dot org
2006-03-01 16:41 ` paul dot richard dot thomas at cea dot fr
2006-03-01 16:42 ` fxcoudert at gcc dot gnu dot org
2006-03-01 16:43 ` paul dot richard dot thomas at cea dot fr
2006-03-01 23:46 ` pault at gcc dot gnu dot org
2006-03-02  9:37 ` fxcoudert at gcc dot gnu dot org
2004-05-07  0:27 [Bug fortran/15335] New: [gfortran] runtime error "Attempt to allocate a non-positive " Tobias dot Schlueter at physik dot uni-muenchen dot de
2004-10-07 23:44 ` [Bug fortran/15335] runtime error "Attempt to allocate a negative " tobi at gcc dot gnu dot org
2004-11-18 12:33 ` pinskia at gcc dot gnu dot org
2004-11-18 13:22 ` paul dot richard dot thomas at cea dot fr
2005-04-18 12:04 ` fxcoudert at gcc dot gnu dot org
2005-04-18 21:32 ` tobi at gcc dot gnu dot org

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).