bugGNU Octave - Bugs: bug #57368, Printf() with +Inf precision...

 
 

bug #57368: Printf() with +Inf precision causes segfault

Submitter:  None
Submitted:  Fri 06 Dec 2019 04:39:55 AM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
Priority:  3 - Low Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  Greg Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * dev
Operating System:  * GNU/Linux Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 06 Dec 2019 09:54:23 PM UTC, comment #6: 

Works for me now, closing report.

Rik <rik5>
Group administrator
Fri 06 Dec 2019 09:05:06 PM UTC, comment #5: 

The dynamic field width parameters are supposed to be int values.  I pushed the following changeset to ensure that they are in the range [0, INT_MAX] before converting to int.  I think INT_MAX should work, but the effective limit appears to be somewhat less.  In any case, this change should prevent crashes for Inf values.

http://hg.savannah.gnu.org/hgweb/octave/rev/61cc648ab034

John W. Eaton <jwe>
Group administrator
Fri 06 Dec 2019 07:41:17 PM UTC, comment #4: 

From the gnulib website,




=== Mailing lists ===

-email is unavailable- is used to discuss most aspects of Gnulib, including development and enhancement requests, as well as bug reports.

=== Getting involved ===

If you think you have found a bug in Gnulib, then please send as complete a report as possible to the mailing list above.

Rik <rik5>
Group administrator
Fri 06 Dec 2019 07:37:49 PM UTC, comment #3: 

Also, from the pritf manpage,


Precision
       An  optional precision, in the form of a period ('.')  followed by an optional decimal digit string.  Instead of
       a decimal digit string one may write "*" or "*m$" (for some decimal integer m) to specify that the precision  is
       given  in the next argument, or in the m-th argument, respectively, which must be of type int.  If the precision
       is given as just '.', the precision is taken to be zero.  A negative precision is taken as if the precision were
       omitted.   This gives the minimum number of digits to appear for d, i, o, u, x, and X conversions, the number of
       digits to appear after the radix character for a, A, e, E, f, and F conversions, the maximum number of  signifi‐
       cant digits for g and G conversions, or the maximum number of characters to be printed from a string for s and S
       conversions.


The precision argument must be of type "int".  I'm not sure what vasprintf is converting +Inf too, but it is outside the expected data range.

Rik <rik5>
Group administrator
Fri 06 Dec 2019 07:32:57 PM UTC, comment #2: 

I just updated Octave's gnulib repo to the latest from gnulib itself, but it doesn't fix the issue.

This bug should be filed upstream with them.

Rik <rik5>
Group administrator
Fri 06 Dec 2019 04:50:16 PM UTC, comment #1: 

Confirmed on the development branch.

This would seem to me fairly simple to avoid by having the programmer check their precision for reasonableness before printing.  Sample code might be


precision = min (precision, 20);


Internally, Octave relies on vasprintf which is supplied by gnulib.  In the long term, this is in an upstream bug that needs to be reported and fixed in that project.

Rik <rik5>
Group administrator
Fri 06 Dec 2019 04:39:55 AM UTC, original submission:  

It's a one line crash:

printf("%.*f", +Inf, 1)

NaN and -Inf are fine.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

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 jwe (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-12-06 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2019-12-06 jwe StatusConfirmed Ready For Test
    2019-12-06 rik5 Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        StatusNone Confirmed
        Release5.1.0 dev

    Back to the top

    Powered by Savane 3.13-caa5.
    Corresponding source code