bugGNU Octave - Bugs: bug #47759, scanf should return min/max value...

 
 

bug #47759: scanf should return min/max value on integer range overflow

Submitted by:  Mike Miller <mtmiller>
Submitted on:  Fri 22 Apr 2016 03:04:08 AM UTC  
 
Category: Octave FunctionSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Matlab Compatibility
Status: FixedAssigned to: Mike Miller <mtmiller>
Originator Name: Open/Closed: Closed
Release: devOperating System: Any

Add a New Comment(Rich Markup)
   

You are not logged in

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

 

Wed 11 May 2016 08:26:50 PM UTC, comment #3:

Fixed with http://hg.savannah.gnu.org/hgweb/octave/rev/4418e579cca6

Mike Miller <mtmiller>
Project AdministratorIn charge of this item.
Tue 26 Apr 2016 05:20:24 PM UTC, comment #2:

I tried an mxe-build with your patch on Windows 10 with the following results:

So the original issue seems to be solved with your patch.

Markus Mützel <mmuetzel>
Project Member
Sat 23 Apr 2016 08:54:16 AM UTC, comment #1:

Matlab does not emit an error message on integer overflow:

For completeness, the same for "%ld" and %lx":

No error message either.

Maybe, mark the respective place in the code anyway stating this is Matlab's behavior. When this would be possible in the future, one might want to emit an error message anyway?

Markus Mützel <mmuetzel>
Project Member
Fri 22 Apr 2016 03:04:08 AM UTC, original submission:

According to tests in bug #47741, Matlab returns the minimum or maximum integer value if the converted value overflows the storage limit of a 32-bit integer (or 64-bit integer if %ld is used).

Octave currently stops conversion when it encounters a value that is out of range.

Does Matlab also return an errmsg string when a value overflows? What does Matlab do for the following:

The attached diff fixes the bug so overflow values are returned as the min/max value possible and conversion continues with the next value, but does not set errmsg. See also bug #46493 for why we can't currently set errmsg on success, but we can at least mark it as something to fix later for compatibility.

Mike Miller <mtmiller>
Project AdministratorIn charge of this item.

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #36978:  scanf-overflow.diff added by mtmiller (3KiB - text/x-diff)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by mmuetzel (Posted a comment)
  • -unavailable- added by mtmiller (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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 11 May 2016 08:26:50 PM UTCmtmillerStatusIn Progress=>Fixed
      Open/ClosedOpen=>Closed
    Fri 22 Apr 2016 03:04:08 AM UTCmtmillerAttached File-=>Added scanf-overflow.diff, #36978

    Back to the top


    Powered by Savane 3.1-cleanup1