Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault on malformed Convex.jl problem #94

Closed
ericphanson opened this issue Jun 8, 2019 · 4 comments
Closed

Segfault on malformed Convex.jl problem #94

ericphanson opened this issue Jun 8, 2019 · 4 comments

Comments

@ericphanson
Copy link

With Convex v0.12.0,

using Convex, ECOS, Test
solver = ECOSSolver()
TOL = 1e-4
x = Variable()
y = Variable()
fix!(x, 1.0)
prob = minimize(y*x, [y >= x, x >= 0.5])
solve!(prob, solver)
@test prob.optval  1.0 atol = TOL

fix!(x, 2.0)
solve!(prob, solver)
@test prob.optval  4.0 atol = TOL

free!(x)
fix!(y, 1.0)
solve!(prob, solver)
@test prob.optval  0.5 atol = TOL

results in a segfault. This is partly Convex.jl's fault, because it creates a problem that doesn't make sense (see jump-dev/Convex.jl#299), but I don't think ECOS should segfault. SCS for example returns NaN.

I'm actually not 100% sure exactly how it's a malformed problem (the why is because x is set to :fixed but has AffineVexity() instead of ConstVexity()). For example,

c, A, b, cones, var_to_ranges, vartypes, conic_constraints = Convex.conic_problem(prob)

gives the abstract problem setup that Convex will then pass to MathProgBase, and I can't see what's wrong with it from there right away.

@odow
Copy link
Member

odow commented Nov 29, 2021

Closing because I can no longer reproduce this:

julia> using Convex, ECOS, Test

julia> solver = ECOS.Optimizer
ECOS.Optimizer

julia> TOL = 1e-4
0.0001

julia> x = Variable()
Variable
size: (1, 1)
sign: real
vexity: affine
id: 181067

julia> y = Variable()
Variable
size: (1, 1)
sign: real
vexity: affine
id: 120994

julia> fix!(x, 1.0)
Variable
size: (1, 1)
sign: real
vexity: constant
id: 181067
value: 1.0

julia> prob = minimize(y*x, [y >= x, x >= 0.5])
minimize
└─ * (affine; real)
   ├─ real variable (id: 120994)
   └─ real variable (fixed) (id: 181067)
subject to
├─ >= constraint (affine)
│  ├─ real variable (id: 120994)
│  └─ real variable (fixed) (id: 181067)
└─ >= constraint (constant)
   ├─ real variable (fixed) (id: 181067)
   └─ 0.5

status: `solve!` not called yet

julia> solve!(prob, solver)

ECOS 2.0.5 - (C) embotech GmbH, Zurich Switzerland, 2012-15. Web: www.embotech.com/ECOS

It     pcost       dcost      gap   pres   dres    k/t    mu     step   sigma     IR    |   BT
 0  +1.000e+00  +1.500e+00  +3e+00  3e-01  2e-01  1e+00  1e+00    ---    ---    1  1  - |  -  - 
 1  +9.503e-01  +9.886e-01  +2e-01  2e-02  1e-02  7e-02  1e-01  0.9402  4e-02   1  0  0 |  0  0
 2  +9.994e-01  +9.999e-01  +3e-03  2e-04  1e-04  7e-04  2e-03  0.9884  1e-04   1  0  0 |  0  0
 3  +1.000e+00  +1.000e+00  +3e-05  2e-06  1e-06  8e-06  2e-05  0.9890  1e-04   1  0  0 |  0  0
 4  +1.000e+00  +1.000e+00  +3e-07  2e-08  2e-08  9e-08  2e-07  0.9890  1e-04   1  0  0 |  0  0
 5  +1.000e+00  +1.000e+00  +4e-09  3e-10  2e-10  1e-09  2e-09  0.9890  1e-04   1  0  0 |  0  0

OPTIMAL (within feastol=2.6e-10, reltol=3.6e-09, abstol=3.6e-09).
Runtime: 0.000207 seconds.


julia> @test prob.optval  1.0 atol = TOL
Test Passed

julia> fix!(x, 2.0)
Variable
size: (1, 1)
sign: real
vexity: constant
id: 181067
value: 2.0

julia> solve!(prob, solver)

ECOS 2.0.5 - (C) embotech GmbH, Zurich Switzerland, 2012-15. Web: www.embotech.com/ECOS

It     pcost       dcost      gap   pres   dres    k/t    mu     step   sigma     IR    |   BT
 0  +4.000e+00  +5.094e+00  +5e+00  1e-01  2e-01  1e+00  2e+00    ---    ---    1  1  - |  -  - 
 1  +3.955e+00  +4.080e+00  +5e-02  4e-03  6e-03  1e-01  1e-01  0.9725  3e-02   1  0  0 |  0  0
 2  +4.000e+00  +4.001e+00  +6e-04  5e-05  6e-05  1e-03  1e-03  0.9890  1e-04   1  0  0 |  0  0
 3  +4.000e+00  +4.000e+00  +7e-06  5e-07  7e-07  1e-05  1e-05  0.9890  1e-04   1  0  0 |  0  0
 4  +4.000e+00  +4.000e+00  +8e-08  6e-09  8e-09  2e-07  1e-07  0.9890  1e-04   1  0  0 |  0  0
 5  +4.000e+00  +4.000e+00  +9e-10  7e-11  9e-11  2e-09  2e-09  0.9890  1e-04   1  0  0 |  0  0

OPTIMAL (within feastol=8.7e-11, reltol=2.3e-10, abstol=9.0e-10).
Runtime: 0.000064 seconds.


julia> @test prob.optval  4.0 atol = TOL
Test Passed

julia> free!(x)
Variable
size: (1, 1)
sign: real
vexity: affine
id: 181067
value: 2.0

julia> fix!(y, 1.0)
Variable
size: (1, 1)
sign: real
vexity: constant
id: 120994
value: 1.0

julia> solve!(prob, solver)

ECOS 2.0.5 - (C) embotech GmbH, Zurich Switzerland, 2012-15. Web: www.embotech.com/ECOS

It     pcost       dcost      gap   pres   dres    k/t    mu     step   sigma     IR    |   BT
 0  +7.500e-01  -3.500e-08  +8e-01  6e-03  1e-08  1e+00  6e-01    ---    ---    1  1  - |  -  - 
 1  +6.151e-01  +4.951e-01  +1e-01  9e-04  7e-09  2e-01  9e-02  0.8529  1e-02   1  0  0 |  0  0
 2  +5.016e-01  +4.982e-01  +3e-03  2e-05  4e-09  3e-03  2e-03  0.9890  1e-02   1  0  0 |  0  0
 3  +5.000e-01  +5.000e-01  +4e-05  2e-07  9e-11  3e-05  2e-05  0.9890  1e-04   1  0  0 |  0  0
 4  +5.000e-01  +5.000e-01  +4e-07  3e-09  2e-12  3e-07  3e-07  0.9890  1e-04   1  0  0 |  0  0
 5  +5.000e-01  +5.000e-01  +5e-09  3e-11  2e-14  4e-09  3e-09  0.9890  1e-04   1  0  0 |  0  0

OPTIMAL (within feastol=2.9e-11, reltol=9.5e-09, abstol=4.8e-09).
Runtime: 0.000071 seconds.


julia> @test prob.optval  0.5 atol = TOL
Test Passed

(convex) pkg> st
      Status `/private/tmp/convex/Project.toml`
  [f65535da] Convex v0.14.18
  [e2685f51] ECOS v0.13.0
  [8dfed614] Test

@odow odow closed this as completed Nov 29, 2021
@ericphanson
Copy link
Author

To reproduce, one probably needs Convex v0.12.0. With jump-dev/Convex.jl#299 I fixed the bug that caused us to emit malformed problems. But maybe it was just a stackoverflow or something like that, which would be undestandable and seems to result in segfaults on MacOS (which I was probably using).

@odow
Copy link
Member

odow commented Nov 29, 2021

That would mean using an older version of ECOS as well and I just re-wrote it :). We can dig deeper if someone ever triggers this again.

@ericphanson
Copy link
Author

Ok, sounds good 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants