bugGNU Octave - Bugs: bug #58505, Handing NAs to glpk() can causes...

 
 

bug #58505: Handing NAs to glpk() can causes several classes of crashes

Submitter:  Jean-Baptiste Mazon <jbmazon>
Submitted:  Sat 06 Jun 2020 05:48:51 AM UTC
   
 
Category:  Octave Function Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Segfault, Bus Error, etc.
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 6.0.90 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Tue 29 Sep 2020 08:16:56 PM UTC, comment #5: 

Thanks. Seems to work now.

Closing as fixed.

Markus Mützel <mmuetzel>
Group administrator
Tue 29 Sep 2020 02:39:54 AM UTC, comment #4: 

After changeset f0588f913755 the test for qp started failing because bounds were no longer allowed to be infinite.  I think that's valid, so I pushed the following additional changeset on stable and merged with default:

http://hg.savannah.gnu.org/hgweb/octave/rev/f864f78440e6

John W. Eaton <jwe>
Group administrator
Mon 28 Sep 2020 07:49:49 PM UTC, comment #3: 

Thanks anonymous for the diff.
I added some BISTs and pushed a similar change here:
https://hg.savannah.gnu.org/hgweb/octave/rev/f0588f913755

Marking as ready for test.

Markus Mützel <mmuetzel>
Group administrator
Wed 29 Jul 2020 12:45:20 AM UTC, comment #2: 

I confirm the crashes with NA. The last problem from OP actually works for me and glpk returns a value.

I agree that the Octave script scripts/optimization/glpk.m should error on any of the input values being NaN or NA. No optimization solver can deal with NaN anyway.

Here is a diff of the proposed changes:

$ diff glpk.m glpk.m.new
492,493c492,493
<   if (all (size (c) > 1) || iscomplex (c) || ischar (c))
<     error ("glpk: C must be a real vector");
---
>   if (all (size (c) > 1) || iscomplex (c) || ischar (c) || any ( isnan (c) ) )
>     error ("glpk: C must be a real vector and free of NaNs");
506a507,509
>   if (any (isnan (A(:) ) ) )
>     error ("glpk: A must not have NaN");
>   endif
520a524,526
>   if (any (isnan (b(:) ) ) )
>     error ("glpk: b must not have NaN");
>   endif
527c533
<     elseif (! isreal (lb) || all (size (lb) > 1) || length (lb) != nx)
---
>     elseif (! isreal (lb) || all (size (lb) > 1) || length (lb) != nx || any (isnan(lb)) )
539c545
<     elseif (! isreal (ub) || all (size (ub) > 1) || length (ub) != nx)
---
>     elseif (! isreal (ub) || all (size (ub) > 1) || length (ub) != nx || any (isnan(ub)) )
582c588
<     elseif (ischar (sense) || all (size (sense) > 1) || ! isreal (sense))
---
>     elseif (ischar (sense) || all (size (sense) > 1) || ! isreal (sense) || any (isnan (sense)))


Anonymous
Sun 07 Jun 2020 09:57:18 AM UTC, comment #1: 

I can confirm the crashes here.

Since development for Octave 5 has stopped, I'm re-targeting the release to version 6.

It is clear that Octave shouldn't segfault in any of these cases.
Since "glpk" is an Octave-only function, we can decide what the desired behavior should be.

For the probably easier case with NaN input:

  • Should Octave throw an error?
  • Should the function return NaN? For all output arguments (errnum!)?
  • Something else?


Markus Mützel <mmuetzel>
Group administrator
Sat 06 Jun 2020 05:48:51 AM UTC, original submission:  

GNU Octave, version 5.2.0
Copyright (C) 2020 John W. Eaton and others.
(...)
Octave was configured for "x86_64-pc-linux-gnu".
(...)
octave:1> glpk(1,NA,1)
Assertion failed: q->lb == q->ub
Error detected in file npp/npp2.c at line 1112
fatal: caught signal Aborted -- stopping myself...
Aborted (core dumped)

octave:2> glpk(1,1,NA)
Assertion failed: p->lb < p->ub
Error detected in file npp/npp3.c at line 894
fatal: caught signal Aborted -- stopping myself...
Aborted (core dumped)

octave:3> glpk(1,1,1,NA)
octave:4> glpk(1,1,1,1,NA)
Assertion failed: q->lb < q->ub
Error detected in file npp/npp3.c at line 295
fatal: caught signal Aborted -- stopping myself...
Aborted (core dumped)

I also have a seemingly deeper one that I haven't managed to extract and reproduce outside of its (deep) context yet.  The parameters as dumped just before the failing call are as follows:

c = [ 0 0 0 0 1 ]'
A = [ 0.00000   1.00000   1.00000   1.00000  -1.00000 ;
      -1.00000        NA   1.00000   0.00000  -1.00000 ;
      -1.00000   1.00000   1.00000   1.00000  -1.00000 ;
      -1.00000   1.00000   1.00000   1.00000  -1.00000 ;
      -1.00000   1.00000   1.00000   1.00000  -1.00000 ;
      -1.00000   1.00000   1.00000   1.00000  -1.00000 ;
      1.00000   1.00000   1.00000   1.00000   0.00000 ]
b = [ 0 0 0 0 0 0 1 ]'
lb = [ 0 0 0 0 -1 ]
ub = [ 1 1 1 1  1 ]
sense = -1
params = struct("msglev",0,"dual",1,"solver",2)
glpk(c,A,b,lb,ub,"LLLLLLS","CCCCC",sense,params)

And the crash as follows:

Scaling...
 A: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00
Problem data seem to be well scaled
EQ: min|aij| =  1.000e+00  max|aij| =  1.000e+00  ratio =  1.000e+00
Assertion failed: x[j] > 0.0 && z[j] > 0.0
Error detected in file draft/glpipm.c at line 508
fatal: caught signal Aborted -- stopping myself...
Aborted (core dumped)

Jean-Baptiste Mazon <jbmazon>

 

(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 mmuetzel (Posted a comment)
  • -email is unavailable- added by jbmazon (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 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-09-29 mmuetzel StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2020-09-28 mmuetzel StatusConfirmed Ready For Test
    2020-06-07 mmuetzel StatusNone Confirmed
        Release5.2.0 6.0.90
        Operating SystemGNU/Linux Any

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code