bugGNU Octave - Bugs: bug #54419, Failure in fread() index causes...


bug #54419: Failure in fread() index causes multiple error statements from get_size() try-catch

Submitted by:  Dan Sebald <sebald>
Submitted on:  Wed 01 Aug 2018 04:14:32 PM UTC  
Category:  Interpreter Severity:  3 - Normal
Priority:  3 - Low Item Group:  Unexpected Error
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  dev Operating System:  GNU/Linux

Add a New Comment(Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Wed 01 Aug 2018 05:02:07 PM UTC, comment #1:

Confirmed, although I'm lowering the priority.

The code execution is stopped by the first error reported. The second error, from the interpreter, is superfluous. But, it could be confusing to those who don't understand Octave.

Rik <rik5>
Project Administrator
Wed 01 Aug 2018 04:14:32 PM UTC, original submission:

For changeset: 25709:02fbbde15308, try the following

octave:1> fn = "ramp10by11.dat";
octave:2> fid = fopen(fn, "w+");
octave:3> fwrite (fid, ones(10,1)*[1:11], "single");
octave:4> frewind (fid);
octave:5> x = fread (fid, [-10, -11], "single");
error: fread: negative value invalid as size specification
error: value on right hand side of assignment is undefined

Inside get_size() of file oct-stream.cc is the following test that is throwing the error on the negative index:

if (d < 0.0)
::error ("%s: negative value invalid as size specification",
who.c_str ());

Normally that ::error() variant is supposed to send control directly back to the command line with error. However, it looks as though the point where get_size() is called is within a try-catch block:

stream::read (const Array<double>& size, octave_idx_type block_size,
oct_data_conv::data_type input_type,
oct_data_conv::data_type output_type,
octave_idx_type skip, mach_info::float_format ffmt,
octave_idx_type& count)
octave_value retval;

if (! stream_ok ())
return retval;
get_size (size, nr, nc, one_elt_size_spec, "fread");
catch (const execution_exception&)
invalid_operation ("fread", "reading");

return retval;

As a result, the ::error() within get_size() doesn't act as expected, and a second error message appears.

Dan Sebald <sebald>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Posted a comment)
  • -email is unavailable- added by sebald (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-08-01 rik5 CategoryLibraries => Interpreter
        Priority5 - Normal => 3 - Low
        StatusNone => Confirmed

    Back to the top

    Powered by Savane 3.4