public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/28105] Check for memory allocations bigger than size_t
       [not found] <bug-28105-4@http.gcc.gnu.org/bugzilla/>
@ 2010-11-19 23:49 ` jb at gcc dot gnu.org
  2010-11-22 22:46 ` jb at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: jb at gcc dot gnu.org @ 2010-11-19 23:49 UTC (permalink / raw)
  To: gcc-bugs

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

Janne Blomqvist <jb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jb at gcc dot gnu.org
         AssignedTo|unassigned at gcc dot       |jb at gcc dot gnu.org
                   |gnu.org                     |

--- Comment #4 from Janne Blomqvist <jb at gcc dot gnu.org> 2010-11-19 23:48:39 UTC ---
Assigning to myself.


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

* [Bug fortran/28105] Check for memory allocations bigger than size_t
       [not found] <bug-28105-4@http.gcc.gnu.org/bugzilla/>
  2010-11-19 23:49 ` [Bug fortran/28105] Check for memory allocations bigger than size_t jb at gcc dot gnu.org
@ 2010-11-22 22:46 ` jb at gcc dot gnu.org
  2010-11-30 21:53 ` jb at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: jb at gcc dot gnu.org @ 2010-11-22 22:46 UTC (permalink / raw)
  To: gcc-bugs

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

Janne Blomqvist <jb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |http://gcc.gnu.org/ml/gcc-p
                   |                            |atches/2010-11/msg02299.htm
                   |                            |l

--- Comment #5 from Janne Blomqvist <jb at gcc dot gnu.org> 2010-11-22 22:43:10 UTC ---
Patch http://gcc.gnu.org/ml/gcc-patches/2010-11/msg02299.html


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

* [Bug fortran/28105] Check for memory allocations bigger than size_t
       [not found] <bug-28105-4@http.gcc.gnu.org/bugzilla/>
  2010-11-19 23:49 ` [Bug fortran/28105] Check for memory allocations bigger than size_t jb at gcc dot gnu.org
  2010-11-22 22:46 ` jb at gcc dot gnu.org
@ 2010-11-30 21:53 ` jb at gcc dot gnu.org
  2010-12-01 11:04 ` burnus at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: jb at gcc dot gnu.org @ 2010-11-30 21:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Janne Blomqvist <jb at gcc dot gnu.org> 2010-11-30 21:33:36 UTC ---
Author: jb
Date: Tue Nov 30 21:33:32 2010
New Revision: 167317

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167317
Log:
PR fortran/28105 Overflow check for ALLOCATE statement

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans-array.c


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

* [Bug fortran/28105] Check for memory allocations bigger than size_t
       [not found] <bug-28105-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2010-11-30 21:53 ` jb at gcc dot gnu.org
@ 2010-12-01 11:04 ` burnus at gcc dot gnu.org
  2010-12-01 14:44 ` jb at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-12-01 11:04 UTC (permalink / raw)
  To: gcc-bugs

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

Tobias Burnus <burnus at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #7 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-12-01 11:04:06 UTC ---
I have played a bit around with the following (which has to be compiled on a
system with 32bit size_t):

   real(8), dimension(1024*1024*1024) :: m
   m(1)= 0
   print *, 1024*1024*1024 ! * 8 -> overflow
   print *, huge(3)
   print *, 2_8**32
   print *, 4_8*1024*1024*1024
   end

However, I fail to get any compile- or run-time error. Expected: As with the
following code, one gets a compile-time error:

$ gfortran -m32 hjff3.f90
.test.f90:1:0: error: size of variable ‘m’ is too large

   real(8), dimension(huge(3)) :: m
   m(1)= 0
   end


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

* [Bug fortran/28105] Check for memory allocations bigger than size_t
       [not found] <bug-28105-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2010-12-01 11:04 ` burnus at gcc dot gnu.org
@ 2010-12-01 14:44 ` jb at gcc dot gnu.org
  2010-12-01 15:39 ` burnus at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: jb at gcc dot gnu.org @ 2010-12-01 14:44 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Janne Blomqvist <jb at gcc dot gnu.org> 2010-12-01 14:43:55 UTC ---
AFAICS the patch I committed in #6 as r167317 only changes how the ALLOCATE
statement is compiled. For automatic and static arrays, different codepaths are
chosen. 

In principle we should be able to catch the example in #7 at compile-time. But
intuitively that would require us to check overflow after constant propagation;
I don't know how easy that would be to do and what other effects such a change
might bring.

Or, perhaps a simpler approach would be to generate the array setup code with
runtime overflow checks, and rely on the optimizers to remove the test at
runtime for constant bounds; that is, essentially what the ALLOCATE code does?


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

* [Bug fortran/28105] Check for memory allocations bigger than size_t
       [not found] <bug-28105-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2010-12-01 14:44 ` jb at gcc dot gnu.org
@ 2010-12-01 15:39 ` burnus at gcc dot gnu.org
  2010-12-02  7:35 ` Joost.VandeVondele at pci dot uzh.ch
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: burnus at gcc dot gnu.org @ 2010-12-01 15:39 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Tobias Burnus <burnus at gcc dot gnu.org> 2010-12-01 15:38:52 UTC ---
(In reply to comment #8)
> For automatic and static arrays, different code paths are chosen.

I think one should try to get some checking working for INTEGER_CST_P only,
i.e. independent whether one uses automatic or static arrays or in the ALLOCATE
statement, a compile-time error should be printed. I am not sure that one needs
a run-time error - and if so, only with -fcheck=mem.

I think one should do something like:

if (INTEGER_CST_P (size))
  {
     if (!host_integerp (DECL_SIZE_UNIT (size), 1))
       goto too_large = true;
     if (TREE_INT_CST_LOW (size)
         > TYPE_MAX_VALUE (sizetype)/TREE_INT_CST_LOW (element_size)
       goto too_large;
  }

if (!host_integerp (DECL_SIZE_UNIT (decl), 1))
  goto too_large;

too_large:
    gfc_error (...);


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

* [Bug fortran/28105] Check for memory allocations bigger than size_t
       [not found] <bug-28105-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2010-12-01 15:39 ` burnus at gcc dot gnu.org
@ 2010-12-02  7:35 ` Joost.VandeVondele at pci dot uzh.ch
  2010-12-15 17:15 ` jb at gcc dot gnu.org
  2013-06-22 13:55 ` dominiq at lps dot ens.fr
  8 siblings, 0 replies; 12+ messages in thread
From: Joost.VandeVondele at pci dot uzh.ch @ 2010-12-02  7:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Joost VandeVondele <Joost.VandeVondele at pci dot uzh.ch> 2010-12-02 07:35:03 UTC ---
BTW, there is some similar thread for C++, maybe ideas can be copied:

http://gcc.gnu.org/ml/gcc/2010-12/msg00053.html


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

* [Bug fortran/28105] Check for memory allocations bigger than size_t
       [not found] <bug-28105-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2010-12-02  7:35 ` Joost.VandeVondele at pci dot uzh.ch
@ 2010-12-15 17:15 ` jb at gcc dot gnu.org
  2013-06-22 13:55 ` dominiq at lps dot ens.fr
  8 siblings, 0 replies; 12+ messages in thread
From: jb at gcc dot gnu.org @ 2010-12-15 17:15 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Janne Blomqvist <jb at gcc dot gnu.org> 2010-12-15 17:15:31 UTC ---
Author: jb
Date: Wed Dec 15 17:15:25 2010
New Revision: 167860

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=167860
Log:
PR 28105 Remove size<0 checks before calling malloc/realloc

Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/trans.c


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

* [Bug fortran/28105] Check for memory allocations bigger than size_t
       [not found] <bug-28105-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2010-12-15 17:15 ` jb at gcc dot gnu.org
@ 2013-06-22 13:55 ` dominiq at lps dot ens.fr
  8 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens.fr @ 2013-06-22 13:55 UTC (permalink / raw)
  To: gcc-bugs

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

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #12 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Since gfortran 4.8.1 up to trunk I get

pr28105.f90:1:0: error: size of variable 'm' is too large
    real(4), dimension(1025*1024*1024) :: m

when compiling 

   real(4), dimension(1025*1024*1024) :: m
   m = 0.
   print *, m(1025*1024*1024)
end

with -m32. Revision 187017 (2012-05-01) does not give any error, but revision
187060 (2012-05-02) does. Closing as FIXED. Please reopen if I am wrong.


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

* [Bug fortran/28105] Check for memory allocations bigger than size_t
  2006-06-20 19:01 [Bug fortran/28105] New: " tobias dot burnus at physik dot fu-berlin dot de
  2007-02-14 15:43 ` [Bug fortran/28105] " manu at gcc dot gnu dot org
  2007-04-18  6:06 ` fxcoudert at gcc dot gnu dot org
@ 2009-04-15 12:30 ` dfranke at gcc dot gnu dot org
  2 siblings, 0 replies; 12+ messages in thread
From: dfranke at gcc dot gnu dot org @ 2009-04-15 12:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from dfranke at gcc dot gnu dot org  2009-04-15 12:30 -------
*** Bug 39772 has been marked as a duplicate of this bug. ***


-- 

dfranke at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jv244 at cam dot ac dot uk


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


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

* [Bug fortran/28105] Check for memory allocations bigger than size_t
  2006-06-20 19:01 [Bug fortran/28105] New: " tobias dot burnus at physik dot fu-berlin dot de
  2007-02-14 15:43 ` [Bug fortran/28105] " manu at gcc dot gnu dot org
@ 2007-04-18  6:06 ` fxcoudert at gcc dot gnu dot org
  2009-04-15 12:30 ` dfranke at gcc dot gnu dot org
  2 siblings, 0 replies; 12+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-04-18  6:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from fxcoudert at gcc dot gnu dot org  2007-04-18 07:05 -------
(In reply to comment #1)
> Will this be appropriate for all front-ends? Then, this is a duplicate of (or
> very related to) bug 18063.

We probably want runtime checks generated by the Fortran front-end for this
case, unlike what people want for C, thus it's not a complete duplicate.


-- 

fxcoudert at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |diagnostic
   Last reconfirmed|0000-00-00 00:00:00         |2007-04-18 07:05:54
               date|                            |


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


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

* [Bug fortran/28105] Check for memory allocations bigger than size_t
  2006-06-20 19:01 [Bug fortran/28105] New: " tobias dot burnus at physik dot fu-berlin dot de
@ 2007-02-14 15:43 ` manu at gcc dot gnu dot org
  2007-04-18  6:06 ` fxcoudert at gcc dot gnu dot org
  2009-04-15 12:30 ` dfranke at gcc dot gnu dot org
  2 siblings, 0 replies; 12+ messages in thread
From: manu at gcc dot gnu dot org @ 2007-02-14 15:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from manu at gcc dot gnu dot org  2007-02-14 15:43 -------
Will this be appropriate for all front-ends? Then, this is a duplicate of (or
very related to) bug 18063.


-- 

manu at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu dot org


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


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

end of thread, other threads:[~2013-06-22 13:55 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-28105-4@http.gcc.gnu.org/bugzilla/>
2010-11-19 23:49 ` [Bug fortran/28105] Check for memory allocations bigger than size_t jb at gcc dot gnu.org
2010-11-22 22:46 ` jb at gcc dot gnu.org
2010-11-30 21:53 ` jb at gcc dot gnu.org
2010-12-01 11:04 ` burnus at gcc dot gnu.org
2010-12-01 14:44 ` jb at gcc dot gnu.org
2010-12-01 15:39 ` burnus at gcc dot gnu.org
2010-12-02  7:35 ` Joost.VandeVondele at pci dot uzh.ch
2010-12-15 17:15 ` jb at gcc dot gnu.org
2013-06-22 13:55 ` dominiq at lps dot ens.fr
2006-06-20 19:01 [Bug fortran/28105] New: " tobias dot burnus at physik dot fu-berlin dot de
2007-02-14 15:43 ` [Bug fortran/28105] " manu at gcc dot gnu dot org
2007-04-18  6:06 ` fxcoudert at gcc dot gnu dot org
2009-04-15 12:30 ` dfranke 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).