bugGNU Octave - Bugs: bug #64080, Incorrect result from reshape.

 
 

bug #64080: Incorrect result from reshape.

Submitter:  None
Submitted:  Thu 20 Apr 2023 08:54:26 PM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  Gyorgy Hexner Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 8.2.0
Operating System:  * GNU/Linux Fixed Release:  8.3.0
Planned Release:  8.3.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 21 Apr 2023 06:12:02 PM UTC, comment #7: 

I would say that my patch does fix this bug report as the title is "Incorrect result from reshape" and reshape() now does correctly return a 0x0 object for sparse inputs.

Whether Octave's signal handling should be changed feels like a separate issue report, or a discussion on Discourse.

Marking this bug as Fixed and closing report.

Rik <rik5>
Group administrator
Fri 21 Apr 2023 03:48:21 AM UTC, comment #6: 

The best the signal handler could do for SIGFPE is something similar to what the one that the SIGINT handler does and set the global interrupt flag that is later noticed by the octave_quit function that is called from various "safe" locations throughout Octave.  Maybe that would be better than simply continuing without interrupt, but it would not stop execution immediately at the point of the signal.  As far as I know, throwing an exception directly from the signal handler would result in undefined behavior and a siglongjmp back to the top-level prompt is also bad because it skips any stack unwinding that would clean up any objects that have been allocated in parent stack frames.

John W. Eaton <jwe>
Group administrator
Fri 21 Apr 2023 02:59:12 AM UTC, comment #5: 

Though it definitely avoids the warnings and the infinite loop,
I am not sure it actually "fixes" the bug.
Why did we get an FPE? Why did we get an infinite loop? Perhaps we should change the signal handler to break the execution and return to octave prompt.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Fri 21 Apr 2023 02:01:08 AM UTC, comment #4: 

I checked in a fix on the stable branch of Octave here http://hg.savannah.gnu.org/hgweb/octave/rev/f18da620ab4d.

Marking as Ready For Test.

Rik <rik5>
Group administrator
Fri 21 Apr 2023 01:30:06 AM UTC, comment #3: 

Confirmed.

This is a peculiarity of sparse matrices because this code with full matrices works


reshape (zeros (0,1), 0, 0)
ans = [](0x0)


Rik <rik5>
Group administrator
Thu 20 Apr 2023 09:42:07 PM UTC, comment #2: 

I guess it comes out of sighandlers.cc

static void
fpe_sig_handler (int)
{
  // FIXME: is there something better we can do?

  std::cerr << "warning: floating point exception" << std::endl;
}


Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 20 Apr 2023 09:06:55 PM UTC, comment #1: 

Confirm on dev as well.

Dmitri.
--

Dmitri A. Sergatskov <dasergatskov>
Thu 20 Apr 2023 08:54:26 PM UTC, original submission:  

The following statement causes an infinite loop of warning: floating point exception.

reshape(sparse(0,1),0,0)

To get out of the loop it is necessary to kill the octave process! I think that the statement should return an empty vector, or matrix.

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)
  • -email is unavailable- added by dasergatskov (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    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 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-04-21 rik5 StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2023-04-21 rik5 StatusConfirmed Ready For Test
        Fixed ReleaseNone 8.3.0
    2023-04-21 rik5 CategoryOctave Function Interpreter
        Item GroupIncorrect Result Segfault, Bus Error, etc.
        StatusNone Confirmed
        Planned ReleaseNone 8.3.0

    Back to the top

    Powered by Savane 3.13-0329.
    Corresponding source code