bugGNU Octave - Bugs: bug #44552, inputdlg crashes GUI with certain...

 
 

bug #44552: inputdlg crashes GUI with certain prompts

Submitter:  None
Submitted:  Mon 16 Mar 2015 04:02:56 PM UTC
   
 
Category:  GUI Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  lostbard
Originator Name:  Dan Zimmerman Originator Email:  -email is unavailable-
Open/Closed:  * Closed Release:  * 4.0.0
Operating System:  * Any Fixed Release:  None
Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 02 Jun 2015 04:39:33 PM UTC, comment #27: 

Retagging release from 4.0.0-rc1 to 4.0.0.

John W. Eaton <jwe>
Group administrator
Wed 18 Mar 2015 10:32:35 AM UTC, comment #26: 

Marking as fixed and closing

John Donoghue <lostbard>
Group Member
Wed 18 Mar 2015 08:10:21 AM UTC, comment #25: 

Works for me to.

Pantxo Diribarne <pantxo>
Group Member
Wed 18 Mar 2015 02:40:39 AM UTC, comment #24: 

Works for me.

Mike Miller <mtmiller>
Group Member
Wed 18 Mar 2015 02:31:03 AM UTC, comment #23: 
John Donoghue <lostbard>
Group Member
Wed 18 Mar 2015 01:56:05 AM UTC, comment #22: 

Testing changes now

John Donoghue <lostbard>
Group Member
Wed 18 Mar 2015 12:29:46 AM UTC, comment #21: 

OK, so it is always supposed to return a column vector regardless of the size of the prompts?  Do you want to combine the changes or should I?

Thanks.

John W. Eaton <jwe>
Group administrator
Tue 17 Mar 2015 04:10:30 PM UTC, comment #20: 

That's better for the input.
The output answer is incorrect still for the GUI link.

Octave:


>> size( inputdlg( {'a','b'} ))
ans =

   1   2

>>


Matlab


>> size( inputdlg( {'a','b'} ))
ans =

   2   1

>>


John Donoghue <lostbard>
Group Member
Tue 17 Mar 2015 03:32:32 PM UTC, comment #19: 

Hmm, and I think we just need a change in inputdlg.m.  See the attached change.  It seems to work for me, but maybe I have it wrong.


(file #33379)

John W. Eaton <jwe>
Group administrator
Tue 17 Mar 2015 03:27:39 PM UTC, comment #18: 

New patch

Also occurs in Linux as well as Windows, so changing OS to any.

(file #33378)

John Donoghue <lostbard>
Group Member
Tue 17 Mar 2015 03:13:33 PM UTC, comment #17: 

Looks like 2 issues occurring.

1) inputdlg.m is expected columns when it does things like: rowscols = zeros (columns (prompt), 2);

2) _octave_link_input_dialog_ returns the 1xX array and should be the Xx1.

So I will change inputdlg to make it columns always and fix (1 and modify octave-link.cc to fix (2.

John Donoghue <lostbard>
Group Member
Tue 17 Mar 2015 03:06:45 PM UTC, comment #16: 

Yes I think was copy/paste and had done a=a(:)'; before the copy of the result.


>> aa = { 'a', 'b'; 'c', 'd'; 'e','f' }
aa =
{
  [1,1] = a
  [2,1] = c
  [3,1] = e
  [1,2] = b
  [2,2] = d
  [3,2] = f
}
>> size(aa)
ans =

   3   2

>>


John Donoghue <lostbard>
Group Member
Tue 17 Mar 2015 02:50:08 PM UTC, comment #15: 

@John D: if it is simple to fix Qt implementation it will avoid distinguishing java/qt implementations in inputdlg.m.

@jwe: this is probably a copy/paste error as the colon at the end of the line should prevent Octave from displaying the value.

Pantxo Diribarne <pantxo>
Group Member
Tue 17 Mar 2015 02:44:21 PM UTC, comment #14: 

Wait, you get a 1x4 cell array for the expression


aa = {'a','b';'c' 'd'};


??  That doesn't look right, and is not what I see.

John W. Eaton <jwe>
Group administrator
Tue 17 Mar 2015 12:15:08 PM UTC, comment #13: 

The command line version (java prompt) returns correctly with size 4 1, so I guess need to change the _octave_link_input_dialog_ function to behave correctly.

John Donoghue <lostbard>
Group Member
Tue 17 Mar 2015 12:09:14 PM UTC, comment #12: 

Running on octave and matlab, and pressing the OK button:

Octave:

>> aa = {'a','b';'c' 'd'};
aa =
{
  [1,1] = a
  [1,2] = c
  [1,3] = b
  [1,4] = d
}
>> r = inputdlg(aa)
r =
{
  [1,1] =
  [1,2] =
  [1,3] =
  [1,4] =
}
>> size(r)
ans =

   1   4


Matlab 2010b:

>> aa = {'a','b';'c','d'}

aa =

    'a'    'b'
    'c'    'd'

>> r = inputdlg(aa)

r =

    ''
    ''
    ''
    ''

>> size(r)

ans =

     4     1


John Donoghue <lostbard>
Group Member
Tue 17 Mar 2015 11:55:43 AM UTC, comment #11: 

@Avinoam: no, according to the tests in comment #7, Matlab always returns a column cell vector.

In inputdlg.m, we have to first reshape the input into a row cell vector to comply with the c++ implementation of the dialog that segfaults otherwise (or fix this implementation) and then reshape the output to be compatible with ML.

Pantxo Diribarne <pantxo>
Group Member
Tue 17 Mar 2015 11:29:50 AM UTC, comment #10: 

All of them fail:


>> aa = {'a','b';'c' 'd'};
>> assert (size (inputdlg (aa)), [4 1]) %click OK button
error: ASSERT errors for:  assert (size (inputdlg (aa)),[4, 1])

  Location  |  Observed  |  Expected  |  Reason
    (1)           1            4         Abs err 3 exceeds tol 0
    (2)           4            1         Abs err 3 exceeds tol 0
>> assert (size (inputdlg (aa(:))), [4 1]) %click OK button
error: ASSERT errors for:  assert (size (inputdlg (aa (:))),[4, 1])

  Location  |  Observed  |  Expected  |  Reason
    (1)           1            4         Abs err 3 exceeds tol 0
    (2)           4            1         Abs err 3 exceeds tol 0
>> assert (size (inputdlg (aa(:).')), [4 1]) %click OK button
error: ASSERT errors for:  assert (size (inputdlg (aa (:).')),[4, 1])

  Location  |  Observed  |  Expected  |  Reason
    (1)           1            4         Abs err 3 exceeds tol 0
    (2)           4            1         Abs err 3 exceeds tol 0


should be


aa = {'a','b';'c' 'd'};
assert (size (inputdlg (aa)), [1 4]) %click OK button
assert (size (inputdlg (aa(:))), [1 4]) %click OK button
assert (size (inputdlg (aa(:).')), [1 4]) %click OK button


Avinoam Kalma <avinoam>
Group Member
Tue 17 Mar 2015 11:25:13 AM UTC, comment #9: 

Do the following test pass (I can't test at the moment)?


aa = {'a','b';'c' 'd'};
assert (size (inputdlg (aa)), [4 1]) %click OK button
assert (size (inputdlg (aa(:))), [4 1]) %click OK button
assert (size (inputdlg (aa(:).')), [4 1]) %click OK button


Also, there should be no space between "prompt" and "(:)" as it is a form of indexing, not a function call.

Pantxo Diribarne <pantxo>
Group Member
Tue 17 Mar 2015 10:54:36 AM UTC, comment #8: 

How about this then

(file #33375)

John Donoghue <lostbard>
Group Member
Tue 17 Mar 2015 08:18:20 AM UTC, comment #7: 

I checked in ML 2013a, the output is a column cell vector whatever the input shape:


>> aa = {'a','b';'c' 'd'}
aa =

    'a'    'b'
    'c'    'd'

>> size (inputdlg (aa))
ans =

     4     1

>> size (inputdlg (aa(:).'))
ans =

     4     1

>> size (inputdlg (aa(:)))
ans =

     4     1


Pantxo Diribarne <pantxo>
Group Member
Tue 17 Mar 2015 07:42:18 AM UTC, comment #6: 

Hi,

@John: you can format the input cell unconditionally ("if" block not needed) in a row vector cell using simply "tmp = prompt(:).'" instead of a potentially slow for loop. If you choose to retain the if block, you should enclose the logical expression in parenthesis to follow Octave coding convention.

Pantxo Diribarne <pantxo>
Group Member
Mon 16 Mar 2015 10:10:55 PM UTC, comment #5: 

Fix will all varied input cells

I need to check whether matlab formats output to be the same format as the input.



(file #33372)

John Donoghue <lostbard>
Group Member
Mon 16 Mar 2015 08:17:39 PM UTC, comment #4: 

Matlab will also handle say a 2x2 array, shoing each element as a  text field, going down the rows, left to right.

John Donoghue <lostbard>
Group Member
Mon 16 Mar 2015 08:15:08 PM UTC, comment #3: 

That appears consistent with matlab.


>> prompt = {'foo',
          'bar'}


creates a 2x1 cell

>> prompt = {'foo',...
          'bar'}


creates a 1x2 array.


However in matlab, inputdlg will work equally the same with both.

John Donoghue <lostbard>
Group Member
Mon 16 Mar 2015 07:08:53 PM UTC, comment #2: 

Note that:


>> prompt = {'foo',...
          'bar'}
prompt =
{
  [1,1] = foo
  [1,2] = bar
}


but


>> prompt = {'foo',
          'bar'}
prompt =
{
  [1,1] = foo
  [2,1] = bar
}


so in the latter case


inputdlg(prompt2')


does work.

Avinoam Kalma <avinoam>
Group Member
Mon 16 Mar 2015 06:01:21 PM UTC, comment #1: 

ALso does it in 4.0.0 rc1 in windows - gui mode only.

Running in cli mode appears to work fine.

John Donoghue <lostbard>
Group Member
Mon 16 Mar 2015 04:02:56 PM UTC, original submission:  

I am attempting to define an input dialog with many fields with complex names and want to split the prompt over many lines.

If I do it with ellipses then everything is okay:



prompt = {'foo',...
          'bar'}
inputdlg(prompt)


However, if I omit the ellipsis as below, the cell array is still parsed fine, but inputdlg crashes Octave entirely, e.g.


prompt2 = {'foo',
          'bar'}
inputdlg(prompt2)


The cell array 'prompt2' is defined, but calling inputdlg on it results in a silent exit.

Perhaps it shouldn't work without the ellipsis, which is fine and fixes my problem for now, but I'd expect it to throw an error instead of crashing.

Experimental 3.8.2 GUI on Windows 7 Ultimate 64 bit, SP1

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #33379:  diffs.txt added by jwe (1KiB - text/plain)
file #33378:  inputdlg3.patch added by lostbard (1KiB - application/octet-stream)
file #33375:  inputdlg2.patch added by lostbard (844B - text/x-patch)
file #33372:  inputdlg.patch added by lostbard (986B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by pantxo (Posted a comment)
  • -email is unavailable- added by avinoam (Posted a comment)
  • -email is unavailable- added by lostbard (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 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-06-02 jwe Release4.0.0-rc1 4.0.0
    2015-03-18 lostbard StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2015-03-18 lostbard StatusConfirmed Ready For Test
    2015-03-18 lostbard Assigned toNone lostbard
    2015-03-17 jwe Attached File- Added diffs.txt, #33379
    2015-03-17 lostbard Attached File- Added inputdlg3.patch, #33378
        Operating SystemMicrosoft Windows Any
    2015-03-17 lostbard Attached File- Added inputdlg2.patch, #33375
    2015-03-16 lostbard Attached File- Added inputdlg.patch, #33372
    2015-03-16 lostbard StatusNone Confirmed
        Release3.8.2 4.0.0-rc1

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code