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

Multiple SOS1 constraints causes segfault #183

Closed
DrChainsaw opened this issue Nov 10, 2021 · 6 comments
Closed

Multiple SOS1 constraints causes segfault #183

DrChainsaw opened this issue Nov 10, 2021 · 6 comments

Comments

@DrChainsaw
Copy link

Tested on 0.9.0 and master. Does not crash on 0.8.1.

Not sure this is the minimum required, but hopefully its small enough to work with:

using JuMP, Cbc

function testsos()
  model = Model(Cbc.Optimizer)

  obj = 0
  psos = nothing
  for i in 1:10
    sos = @variable(model, [1:10, 1:10], Bin)
    @constraint(model,[j=1:10], sos[j, :] in SOS1(1:10))
    @constraint(model,[j=1:10], sum(sos[j, :]) == 1)
    obj = @expression(model, obj + sum(sos))
    if i > 1
      # Removing this constraint seems to make the error much less likely
      @constraint(model, sos .== psos)
    end
    psos = sos
  end

  @objective(model, Max, obj)
  optimize!(model)
end

julia> versioninfo()
Julia Version 1.7.0-rc2
Commit f23fc0d27a (2021-10-20 12:45 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-5820K CPU @ 3.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, haswell)
Environment:
  JULIA_DEPOT_PATH = E:/Programs/julia/.julia

Its not fully deterministic, but happens in about 80% of cases for me and when it crashes it does so at slightly different times. Here is one example:

julia> testsos()
Welcome to the CBC MILP Solver
Version: 2.10.5
Build Date: Jan  1 1970

command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is 100 - 0.00 seconds
PS E:\Programs\julia\.julia\dev\NaiveNASflux> $LASTEXITCODE
-1073740940

Note that it crashes without any error message, but the exit code is some kind of access violation.

In the following CI job I got a better error message which seems to stem from the binary:
https://github.com/DrChainsaw/NaiveNASflux.jl/runs/4169087947?check_suite_focus=true#step:6:197

Commenting out this line makes the testcase pass:
https://github.com/DrChainsaw/NaiveNASflux.jl/blob/863761f83cec80e0701f086ad06d4681d82c9b7f/src/constraints.jl#L315
Line is redundant due to line below btw, but I thought it could speed up the solver.

@odow
Copy link
Member

odow commented Nov 10, 2021

I managed to trigger it on Mac:

julia> testsos()
Welcome to the CBC MILP Solver 
Version: 2.10.5 
Build Date: Apr 14 2021 

command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is 100 - 0.00 seconds
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9474 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9687 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9685 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9685 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9685 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9685 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9685 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9685 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 8982 substitutions
Cgl0004I processed model has 18064 rows, 999 columns (999 integer (999 of which binary)) and 36928 elements
Cutoff increment increased from 1e-05 to 0.9999
Cbc0038I Initial state - 0 integers unsatisfied sum - 0
Cbc0038I Solution found of -100
Cbc0038I Before mini branch and bound, 999 integers at bound fixed and 0 continuous
Cbc0038I Mini branch and bound did not improve solution (1.19 seconds)
Cbc0038I After 1.19 seconds - Feasibility pump exiting with objective of -100 - took 0.02 seconds

signal (11): Segmentation fault: 11
in expression starting at REPL[5]:1
_ZN6CbcSOS14feasibleRegionEv at /Users/oscar/.julia/artifacts/82ebdcaddd0b3f59481fe39e33722ee0f5317c21/lib/libCbc.3.10.5.dylib (unknown line)
_ZNK9CbcObject14feasibleRegionEP18OsiSolverInterfacePK23OsiBranchingInformation at /Users/oscar/.julia/artifacts/82ebdcaddd0b3f59481fe39e33722ee0f5317c21/lib/libCbc.3.10.5.dylib (unknown line)
_ZN8CbcModel13checkSolutionEdPdid at /Users/oscar/.julia/artifacts/82ebdcaddd0b3f59481fe39e33722ee0f5317c21/lib/libCbc.3.10.5.dylib (unknown line)
_ZN8CbcModel15setBestSolutionE11CBC_MessageRdPKdi at /Users/oscar/.julia/artifacts/82ebdcaddd0b3f59481fe39e33722ee0f5317c21/lib/libCbc.3.10.5.dylib (unknown line)
_ZN8CbcModel18doHeuristicsAtRootEi at /Users/oscar/.julia/artifacts/82ebdcaddd0b3f59481fe39e33722ee0f5317c21/lib/libCbc.3.10.5.dylib (unknown line)
_ZN8CbcModel14branchAndBoundEi at /Users/oscar/.julia/artifacts/82ebdcaddd0b3f59481fe39e33722ee0f5317c21/lib/libCbc.3.10.5.dylib (unknown line)
_Z8CbcMain1iPPKcR8CbcModelPFiPS2_iER19CbcSolverUsefulData at /Users/oscar/.julia/artifacts/82ebdcaddd0b3f59481fe39e33722ee0f5317c21/lib/libCbcSolver.3.10.5.dylib (unknown line)
Cbc_solve at /Users/oscar/.julia/artifacts/82ebdcaddd0b3f59481fe39e33722ee0f5317c21/lib/libCbcSolver.3.10.5.dylib (unknown line)
Cbc_solve at /Users/oscar/.julia/packages/Cbc/tjJNj/src/gen/libcbc_api.jl:301 [inlined]
optimize! at /Users/oscar/.julia/packages/Cbc/tjJNj/src/MOI_wrapper/MOI_wrapper.jl:741
optimize! at /Users/oscar/.julia/packages/MathOptInterface/jPhq9/src/MathOptInterface.jl:81 [inlined]
optimize! at /Users/oscar/.julia/packages/MathOptInterface/jPhq9/src/Utilities/cachingoptimizer.jl:285
unknown function (ip: 0x14a124646)
optimize! at /Users/oscar/.julia/packages/MathOptInterface/jPhq9/src/Bridges/bridge_optimizer.jl:348 [inlined]
optimize! at /Users/oscar/.julia/packages/MathOptInterface/jPhq9/src/MathOptInterface.jl:81 [inlined]
optimize! at /Users/oscar/.julia/packages/MathOptInterface/jPhq9/src/Utilities/cachingoptimizer.jl:285
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
#optimize!#121 at /Users/oscar/.julia/packages/JuMP/yP8fy/src/optimizer_interface.jl:195
optimize! at /Users/oscar/.julia/packages/JuMP/yP8fy/src/optimizer_interface.jl:167 [inlined]
optimize! at /Users/oscar/.julia/packages/JuMP/yP8fy/src/optimizer_interface.jl:167 [inlined]
testsos at ./REPL[4]:19
unknown function (ip: 0x14a0d5d6c)
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
do_call at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
eval_body at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_interpret_toplevel_thunk at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_toplevel_eval_flex at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_toplevel_eval_flex at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_toplevel_eval_in at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
eval at ./boot.jl:360 [inlined]
eval_user_input at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:139
repl_backend_loop at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:200
start_repl_backend at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:185
#run_repl#42 at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:317
run_repl at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:305
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
#874 at ./client.jl:387
jfptr_YY.874_23727.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
jl_f__call_latest at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
#invokelatest#2 at ./essentials.jl:708 [inlined]
invokelatest at ./essentials.jl:706 [inlined]
run_main_repl at ./client.jl:372
exec_options at ./client.jl:302
_start at ./client.jl:485
jfptr__start_37496.clone_1 at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/sys.dylib (unknown line)
jl_apply_generic at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
true_main at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
repl_entrypoint at /Applications/Julia-1.6.app/Contents/Resources/julia/lib/julia/libjulia-internal.1.6.dylib (unknown line)
Allocations: 60106885 (Pool: 60087500; Big: 19385); GC: 59
zsh: segmentation fault  ~/julia --project=cbc

For contrast, here's a successful solve:

julia> testsos()
Welcome to the CBC MILP Solver 
Version: 2.10.5 
Build Date: Apr 14 2021 

command line - Cbc_C_Interface -solve -quit (default strategy 1)
Continuous objective value is 100 - 0.00 seconds
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9474 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9687 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9685 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9685 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9685 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9685 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9685 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 9685 substitutions
Cgl0003I 0 fixed, 0 tightened bounds, 0 strengthened rows, 8982 substitutions
Cgl0004I processed model has 18064 rows, 999 columns (999 integer (999 of which binary)) and 36928 elements
Cutoff increment increased from 1e-05 to 0.9999
Cbc0036I Heuristics switched off as 1 branching objects are of wrong type
Cbc0004I Integer solution of -100 found after 0 iterations and 0 nodes (1.17 seconds)
Cbc0001I Search completed - best objective -100, took 0 iterations and 0 nodes (1.18 seconds)
Cbc0035I Maximum depth 0, 0 variables fixed on reduced cost
Cuts at root node changed objective from -100 to -100
Probing was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Gomory was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Knapsack was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
Clique was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
MixedIntegerRounding2 was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
FlowCover was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
TwoMirCuts was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)
ZeroHalf was tried 0 times and created 0 cuts of which 0 were active after adding rounds of cuts (0.000 seconds)

Result - Optimal solution found

Objective value:                100.00000000
Enumerated nodes:               0
Total iterations:               0
Time (CPU seconds):             1.23
Time (Wallclock seconds):       1.33

Total time (CPU seconds):       1.23   (Wallclock seconds):       1.33

@jd-lara
Copy link

jd-lara commented Dec 1, 2021

@odow I can report to get the same issue in PowerSimulations.jl in the tests of SOS cost functions.

@odow
Copy link
Member

odow commented Dec 1, 2021

Does #184 fix it? I forgot about this PR.

@jd-lara
Copy link

jd-lara commented Dec 1, 2021

Haven't tried with this PR but also master is giving a different result (when there are SOS) in the tests and it isn't consistent with the results from SCIP. Need to test more the SOS issues in CBC

@odow
Copy link
Member

odow commented Dec 1, 2021

Closed by #184. There are known issues with SOS and Cbc: #151

@odow odow closed this as completed Dec 1, 2021
@jd-lara
Copy link

jd-lara commented Dec 3, 2021

@odow we are still observing this issue in PowerSimulations testing. I had to comment out the tests because it happens in CI but not locally in MacOS

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

3 participants