bugGNU Octave - Bugs: bug #41648, fread not working with skip...

 
 

bug #41648: fread not working with skip parameter

Submitted by:  None
Submitted on:  Thu 20 Feb 2014 06:03:11 PM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Regression
Status: FixedAssigned to: None
Originator Name: Tiago LoureiroOriginator Email: -unavailable-
Open/Closed: ClosedRelease: 3.8.0
Operating System: Microsoft Windows

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

(Jump to the original submission Jump to the original submission)

Sat 22 Feb 2014 08:03:21 PM UTC, comment #7:

Everything checks out now and fread seems to behave as it did in 3.6.4. Closing report.

Rik <rik5>
Project Administrator
Sat 22 Feb 2014 06:07:41 PM UTC, comment #6:

I checked in the following additional change:

http://hg.savannah.gnu.org/hgweb/octave/rev/0bdecd41b2dd

John W. Eaton <jwe>
Project Administrator
Sat 22 Feb 2014 04:19:34 PM UTC, comment #5:

The patch is almost perfect. The only difference now is that when the read + skip reaches the EOF the 3.8.1 version adds a zero element while the 3.6.4 version correctly finds no data to read and doesn't append a zero element.

Example:

Similarly

Rik <rik5>
Project Administrator
Fri 21 Feb 2014 11:15:09 PM UTC, comment #4:

Rik:

I modified your patch and checked it in:

http://hg.savannah.gnu.org/hgweb/octave/rev/fdd27f68b011

I think this fixes the new problem you reported, plus another that I found while testing (skipping past the end of the file was not skipping when it should have skipped to EOF). If you agree that the problems are fixed, please close this report.

Thanks.

John W. Eaton <jwe>
Project Administrator
Fri 21 Feb 2014 12:26:07 AM UTC, comment #3:

I've attached a patch that fixes the skip problem for me.

I will say that this seems to have exposed another issue. When I run the following code I get a 2-column output which is most definitely wrong.

This seems related, although my patch doesn't fix it so perhaps it should be a different bug report.

(file #30624)

Rik <rik5>
Project Administrator
Fri 21 Feb 2014 12:20:02 AM UTC, comment #2:

I probably broke it when I tried to make fread more efficient. I'll try to take a look at this, but if someone else would like to work on it just let me know that you are.

John W. Eaton <jwe>
Project Administrator
Thu 20 Feb 2014 11:52:45 PM UTC, comment #1:

Running the first example in version 3.6.4 does yield [0, 2, 4, ...] so something was broken between then and the 3.8.0 release. Marking the bug as confirmed.

Rik <rik5>
Project Administrator
Thu 20 Feb 2014 06:03:11 PM UTC, original submission:

The fread function is not behaving correctly when skipping after a read.

With the following data in a binary file (attached):

000102030405060708090A0B0C0D0E0F

Reading it with the following commands:

should yield (in hex):

but returns instead (in hex):

It is interesting to note that if called sequentially like this with skip=1:

the correct sequence is read.

However, if called like this:

it yields a strange sequence:

Note the first two bytes being read correctly, and then the skip is forgotten and the rest of the file is read. The expected sequence would be instead:

Finally, when doing the following:

octave crashes with the message "Aborted".

It is as if it is getting confused between bytes to read and elements to read, and that the logic of whether to skip or not is broken.

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #30624:  patch.fread_skip added by rik5 (679B - application/octet-stream)
file #30618:  test.bin added by None (16B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sat 22 Feb 2014 08:03:21 PM UTCrik5StatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Fri 21 Feb 2014 12:26:07 AM UTCrik5Attached File-=>Added patch.fread_skip, #30624
      Assigned tojwe=>None
    Fri 21 Feb 2014 12:20:02 AM UTCjweAssigned toNone=>jwe
    Thu 20 Feb 2014 11:52:45 PM UTCrik5StatusNone=>Confirmed
    Thu 20 Feb 2014 06:03:11 PM UTCNoneAttached File-=>Added test.bin, #30618

    Back to the top


    Powered by Savane 3.1-cleanup1