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

Segmentation fault: 11 #33

Closed
gshaikov opened this issue Sep 4, 2019 · 4 comments · Fixed by #37
Closed

Segmentation fault: 11 #33

gshaikov opened this issue Sep 4, 2019 · 4 comments · Fixed by #37

Comments

@gshaikov
Copy link

gshaikov commented Sep 4, 2019

I am running the following simple script:

import osqp
import numpy as np
from scipy.sparse import csc_matrix

P = np.array([[1,0], [0,1]])
q = np.array([-1,-1])
A = np.array([[1,0], [0,1]])
l = np.array([0,0])
u = np.array([1,1])

P = csc_matrix(P)
A = csc_matrix(A)

settings = {
    'verbose': True,
}

# This works
m = osqp.OSQP()
m.setup(P=P, q=q, A=A, l=l, u=u, **settings)
results = m.solve()
print(results.x)  # [0.99895712 0.99895712]

# This fails with Segmentation fault: 11
results = osqp.solve(P=P, q=q, A=A, l=l, u=u, **settings)
print(results.x)

Creating OSQP object and calling a solve method on it works fine.
The value of x is [0.99895712 0.99895712].

Direct invocation of osqp.solve terminates with Segmentation fault: 11.

Setup:
MacBook Pro, MacOS Mojave 10.14.6
Python 3.7.2
OSQP 0.6.1
numpy 1.16.2
scipy 1.2.2

@bstellato bstellato mentioned this issue Sep 4, 2019
@bstellato
Copy link
Contributor

I just tried your code and it seems to give the segfault when verbose=True. Have you tried it with False instead? I will look into a fix.

@sbarratt
Copy link

sbarratt commented Sep 5, 2019

@bstellato I'm getting a seg fault with verbose=False when running 50 in parallel. Here's the code

import osqp
import numpy as np
import scipy as sp
from scipy import sparse
from multiprocessing.pool import ThreadPool

def f(i):
    m = 30
    n = 20
    Ad = sparse.random(m, n, density=0.7, format='csc')
    b = np.random.randn(m)

    # OSQP data
    P = sparse.block_diag([sparse.csc_matrix((n, n)), sparse.eye(m)], format='csc')
    q = np.zeros(n+m)
    A = sparse.vstack([
            sparse.hstack([Ad, -sparse.eye(m)]),
            sparse.hstack([sparse.eye(n), sparse.csc_matrix((n, m))])], format='csc')
    l = np.hstack([b, np.zeros(n)])
    u = np.hstack([b, np.ones(n)])

    # Setup workspace
    osqp.solve(P, q, A, l, u, verbose=False)

pool = ThreadPool(4)
pool.map(f, range(50))

@bstellato
Copy link
Contributor

I think the printing issue was related to this cvxgrp/scs#48 I will try to fix it tomorrow together with your segfault problem.

@gshaikov
Copy link
Author

gshaikov commented Sep 6, 2019

@bstellato thank you for the prompt response! You are right, verbose=False solved the second case.

bstellato added a commit that referenced this issue Oct 29, 2019
bstellato added a commit that referenced this issue Nov 1, 2019
* Started adding changes but need to fix print definition in suitesparse

* Fix #33

* Minor typo + clearer comments on longs

* Try to fix python 2 on mac

* Revert "Try to fix python 2 on mac"

This reverts commit d9c2aeb.

* Allow failures on python 2

* Run python 2.7 but allow it to fail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants