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

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

[Octave-bug-tracker] [bug #63803] Saving causes OOM, crash, and loss of


From: Rik
Subject: [Octave-bug-tracker] [bug #63803] Saving causes OOM, crash, and loss of already saved data
Date: Tue, 14 Feb 2023 17:58:35 -0500 (EST)

Follow-up Comment #8, bug #63803 (project octave):

@Arun: I can confirm that memory usage is very small now.  I also discovered
the '-t' argument to free so I didn't even need to use a while loop in the
shell.

This change definitely needs to be propagated across all of the various
save_XXX routines.  A lot of code used to use the fortran_vec() method to get
a pointer to the data contained, and I don't think we were always careful
about using "const" modifier even when we knew it was read-only data.  The
issue is also present in the load_binary routines.  This is the code for
load_binary in ov-bool-mat.cc


  octave_idx_type nel = dv.numel ();
  OCTAVE_LOCAL_BUFFER (char, htmp, nel);
  if (! is.read (htmp, nel))
    return false;
  boolNDArray m(dv);
  bool *mtmp = m.fortran_vec ();
  for (octave_idx_type i = 0; i < nel; i++)
    mtmp[i] = (htmp[i] ? 1 : 0);
  m_matrix = m;


Arguably, one still might want to keep it this way because the file is first
read into a temporary variable (htmp) and only then copied to its true
destination.  If the read fails, then the destination is not harmed.  If
Octave read directly into destination then a partial, corrupted read would
result in a partial, corrupted variable in Octave.


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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