octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #58790] Octave closes unexpectedly when memory


From: John W. Eaton
Subject: [Octave-bug-tracker] [bug #58790] Octave closes unexpectedly when memory allocation fails (Windows 32bit executable)
Date: Fri, 14 Aug 2020 11:21:43 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Firefox/68.0

Follow-up Comment #19, bug #58790 (project octave):

If I understand correctly, the problem is not that the memory allocation
fails, but that we are failing to detect overflow when computing the total
array size?

Allocating the block of memory should be done with operator new, so it should
throw an error if the array can't be allocated and we should be catching that
exception.

But if the calculation overflows, then I'm not sure what happens.  If we are
not properly detecting possible overflow of the array size calculation, then
we should be able to do a better job there.  Gnulib has macros for checking
whether integer operations overflow, or we could (conditionally) use things
like __builtin_mul_overflow to multiply dimensions and check for overflow.

I recently noticed that Sundials(?) was using the portable snippets library
for this job.  Perhaps we could use that or at least borrow ideas from it. 
See, for example, 
https://github.com/nemequ/portable-snippets/tree/master/safe-math




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58790>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]