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

 
 

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

Submitted by:  Jean-Baptiste Mazon <jbmazon>
Submitted on:  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:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  6.0.90 Operating System:  Any

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

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>
Project Member
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 mmuetzel (Posted a comment)
  • -email is unavailable- added by jbmazon (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-06-07 mmuetzel StatusNone => Confirmed
        Release5.2.0 => 6.0.90
        Operating SystemGNU/Linux => Any

    Back to the top


    Powered by Savane 3.5