bugGNU Octave - Bugs: bug #43351, format + crashes the GUI

 
 

bug #43351: format + crashes the GUI

Submitter:  None
Submitted:  Fri 03 Oct 2014 07:51:41 PM UTC
   
 
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  Erik Wanta Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 3.8.2
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 07 Oct 2014 12:57:04 PM UTC, comment #8: 

The crash was fixed with 4b6f87c6739f, the default format "+- " and docstring with cset 97eea1e2d9ff (http://hg.savannah.gnu.org/hgweb/octave/rev/97eea1e2d9ff) in gui-release which should get the 4.0 release.

Andreas Weber <andy1978>
Group Member
Sun 05 Oct 2014 06:24:38 PM UTC, comment #7: 

Yes I think we should also fix the default behavior.

The current default is that only a "+" is printed for positive elements; zero and negative element positions are left blank.
This is less useful for the average user: I suppose the predominant motive to use "format +" is to check which elements are non-zero.

One can use spy as well but 'format +' is easier and quicker.

Philip Nienhuis <philipnienhuis>
Group Member
Sun 05 Oct 2014 10:32:43 AM UTC, comment #6: 

Btw, it is possible to change plus_format_chars:

octave:1> a = [1 -1 0;-2 0 2];
octave:2> a
a =

   1  -1   0
  -2   0   2

octave:3> format +
octave:4> a
a =

+
  +

octave:5> format("+", "xyz")
octave:6> a
a =

xyz
yzx

octave:7> format("+", "+- ")
octave:8> a
a =

+-
- +


But the help says (as Philip already stated) 'plus CHARS', for example '+ "+-."'.

I think the current octave implementation (with two args) is plausible here and we should fix the documentation.


Andreas Weber <andy1978>
Group Member
Sun 05 Oct 2014 09:42:03 AM UTC, comment #5: 

Fixed in cset 4b6f87c6739f.

The reason for this was in short_disp from octave_base_scalar and octave_base_matrix which is only used for the GUI workspace in symtab.cc (not used in the CLI).

What should we do with the matlab incompatibility with "format +"? Should we change the defaults to "+- "?

Andreas Weber <andy1978>
Group Member
Sat 04 Oct 2014 10:27:21 AM UTC, comment #4: 

In pr-output.cc the chars for "format plus" are defined as

// First char for > 0, second for < 0, third for == 0.
static std::string plus_format_chars = "+  ";


(not as "+- " as matlab does but this isn't the problem here, only a ML incompatibility)

I think the problem is in ov-base-mat.cc:479 (default branch)

std::ostringstream buf;
octave_print_internal (buf, matrix(j*nr+i));
std::string tmp = buf.str ();
size_t pos = tmp.find_first_not_of (" ");
os << tmp.substr (pos);


where "size_t pos = tmp.find_first_not_of (" ");" returns "string::npos" (not found) and then "os << tmp.substr (pos);" throws a out_of_range which isn't cached.

The same problem is also in ov-base-scalar.cc for "a=-1;format +"

Andreas Weber <andy1978>
Group Member
Sat 04 Oct 2014 09:59:47 AM UTC, comment #3: 

On 4.1.0+ CLI I get no crash (but it looks intruiging):


octave:1> a=[1, 2; -3, 4]
a =

   1   2
  -3   4

octave:2> format +
octave:3> a
a =

++
 +

octave:4> a=[5, 6; -7, 8]
a =

++
 +

octave:5>


I get the same on 3.6.4-MSVC:

octave-3.6.4.exe:1> a=[1, 2; -3, 4]
a =

   1   2
  -3   4

octave-3.6.4.exe:2> format +
octave-3.6.4.exe:3> a
a =

++
 +

octave-3.6.4.exe:4> a=[5, 6; -7, 8]
a =

++
 +

octave-3.6.4.exe:5>


So + only prints for positive elements rather than non-zero elements, which doesn't conform to "help format".

format '+ "+-."' isn't accepted, format + "abc" is but does nothing:

octave:3> format '+ "+-."'
error: format: unrecognized format state '+ "+-."'
octave:3> format + "abc"
octave:4> a
a =

   1   2  -3   4


Matlab r2014b prerel does:

>> a=[5, 6; -7, 8]
a =
     5     6
    -7     8
>> format +
>> a
a =
++
-+
>>


and Matlab's 'help format' says":

format +       The symbols +, - and blank are printed
                     for positive, negative and zero elements.
                     Imaginary parts are ignored.


so it seems Octave's format command is also ML-incompatible (but I like Octave's intended behavior better)

Philip Nienhuis <philipnienhuis>
Group Member
Sat 04 Oct 2014 09:36:33 AM UTC, comment #2: 

Confirmed (hard crash) on Windows as well w. 3.8.0, 3.8.2-64bit, 3.9.0+ & 4.1.0+

It works fine with 3.6.4-MSVC

OS -> any, I'll leave 'Release' as it is entered

Philip Nienhuis <philipnienhuis>
Group Member
Sat 04 Oct 2014 04:29:25 AM UTC, comment #1: 

I can confirm this on the actual gui branch.

Torsten Lilge <ttl>
Group Member
Fri 03 Oct 2014 07:51:41 PM UTC, original submission:  

./octave --force-gui

a=[1,2,-3,4]
format +

octave exited with signal 6

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

Digest:
   bug dependencies.

 

Carbon-Copy List
  • -email is unavailable- added by andy1978 (Posted a comment)
  • -email is unavailable- added by ttl (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 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2014-10-21 mtmiller Dependencies- bugs #43451 is dependent
    2014-10-07 andy1978 Open/ClosedOpen Closed
    2014-10-07 andy1978 StatusConfirmed Fixed
    2014-10-04 philipnienhuis Operating SystemGNU/Linux Any
    2014-10-04 ttl StatusNone Confirmed

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code