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

REPL crashing on ctrl+c? #45

Closed
leotac opened this issue Jul 30, 2015 · 8 comments
Closed

REPL crashing on ctrl+c? #45

leotac opened this issue Jul 30, 2015 · 8 comments

Comments

@leotac
Copy link
Contributor

leotac commented Jul 30, 2015

I'm sure it's a known issue, but ctrl+c causes the REPL to crash (brutal segfault).
[If it only happens to me, I'd like to find out why :)]

Related: with Gurobi, ctrl+c takes me back to the REPL but the solver keeps running in the background, until it completes (or you quit the REPL) -- only marginally less annoying than a crash. Should probably open an issue there as well, if there isn't one already.

@joehuchette
Copy link
Contributor

Yeah I see this as well, I mostly use CPLEX but I think I've noticed it for other solvers as well. I have pretty much no idea how to work around this though, but @mlubin maybe has some thoughts?

@mlubin
Copy link
Member

mlubin commented Jul 30, 2015

I've seen similar issues but haven't been following the state of signal
handling in julia.
CC @tkelman @vtjnash
On Jul 30, 2015 1:02 PM, "Joey Huchette" [email protected] wrote:

Yeah I see this as well, I mostly use CPLEX but I think I've noticed it for
other solvers as well. I have pretty much no idea how to work around this
though, but @mlubin https://github.com/mlubin maybe has some thoughts?


Reply to this email directly or view it on GitHub
#45 (comment).

@tkelman
Copy link
Contributor

tkelman commented Jul 31, 2015

might need some sigint fiddling? ref JuliaLang/julia#2622 and JuliaLang/julia#12309

@joehuchette
Copy link
Contributor

So just wrapping e.g.

stat = disable_sigint() do
    @cpx_ccall(mipopt, Cint, (Ptr{Void}, Ptr{Void}), model.env.ptr, model.lp)
end

means CPLEX just keeps running after CTRL+C, which IMO is less desirable than a brutal segfault. Ideally we'd want to propagate the SIGINT to CPLEX so it can fail gracefully, but I'm not certain how to do that.

@leotac
Copy link
Contributor Author

leotac commented Aug 3, 2015

The CPLEX callable library does provide a function to terminate it gracefully: http://www-01.ibm.com/support/knowledgecenter/SSSA5P_12.6.2/ilog.odms.cplex.help/refcallablelibrary/cpxapi/setterminate.html?cp=SSSA5P_12.6.2%2F2-8-0-30-2&lang=en
I wonder if it's possible to (temporarily) replace the default Julia signal handler with something that ccalls CPXsetterminate(). Make sense?

@joehuchette
Copy link
Contributor

Looks like maybe we could do something like this:

try 
    @cpx_ccall(mipopt, Cint, (Ptr{Void}, Ptr{Void}), model.env.ptr, model.lp)
catch ex
    if isa(ex, InterruptException)
        @cpx_ccall(setterminate, Cint, (Ptr{Void}, Ptr{Void}), model.env.ptr, CPLEX_SIGINT)
    else
        rethrow(ex)
    end
end

(ref http://stackoverflow.com/questions/20831290/julia-handle-keyboard-interrupt)

@joehuchette
Copy link
Contributor

I don't know what CPLEX_SIGINT should be, though.

@joehuchette
Copy link
Contributor

In my not too exhaustive testing, ab71579 seems to give the expected behavior now. Reopen if I'm wrong!

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

4 participants