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

SIGSEGV on macOS when run in parallel #1005

Closed
yongqli opened this issue Nov 15, 2022 · 6 comments
Closed

SIGSEGV on macOS when run in parallel #1005

yongqli opened this issue Nov 15, 2022 · 6 comments
Assignees

Comments

@yongqli
Copy link

yongqli commented Nov 15, 2022

When I try to run HiGHS solvers from multiple threads using the Rust binding, I get SIGSEGV on macOS:

lldb output:

Process 66711 stopped
* thread #35, stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
    frame #0: 0x0000000100170c0d `HighsMipSolverData::evaluateRootNode() [inlined] HighsSplitDeque::getCurrentHead(this=0x0000000000000000) const at HighsSplitDeque.h:481:49 [opt]
   478
   479     int getOwnerId() const { return ownerData.ownerId; }
   480
-> 481     int getCurrentHead() const { return ownerData.head; }
   482
   483     HighsSplitDeque* getWorkerById(int id) const {
   484       return ownerData.workers[id].get();

See also rust-or/highs#6

@jajhall
Copy link
Sponsor Member

jajhall commented Nov 15, 2022

Any idea what might be happening @lgottwald ?

@lgottwald
Copy link
Contributor

lgottwald commented Nov 15, 2022 via email

@yongqli
Copy link
Author

yongqli commented Nov 15, 2022

I'm consistently getting a SIGSEGV on macOS with the following:

use highs::ColProblem;
use rayon::prelude::*;

fn test_higs() {
    let rows = [0, -1, 2, 0, 0, -1, 2];
    let cols = [
        (18, vec![(1, -1), (2, 1), (6, 2)]),
        (20, vec![(1, -1), (2, 2), (6, 1)]),
        (12, vec![(1, -1), (5, -1), (6, 1)]),
        (9, vec![(1, -1), (5, -1), (6, 2)]),
        (6, vec![(1, -1), (6, 1)]),
        (4, vec![(2, 1)]),
        (7, vec![(2, 1), (5, -1)]),
        (12, vec![(2, 1), (5, -1), (6, 1)]),
    ];
    let mut problem = ColProblem::new();
    let rows = rows.iter().map(|&v| {
        let v = v as f64;
        problem.add_row(v..=v)
    }).collect::<Vec<_>>();
    for (cost, facs) in cols {
        problem.add_integer_column(
            cost as f64,
            0..,
            facs.iter().map(|&(r, v)| (rows[r], v as f64)),
        );
    }
    problem.optimise(highs::Sense::Minimise).solve();
}

fn main() {
    (0..3).into_par_iter().for_each(|_| {
        test_higs()
    });
}
[dependencies]
highs = "1.2.2"
rayon = "1.0"

Can anyone else confirm that they are able to reproduce this?

@yongqli
Copy link
Author

yongqli commented Nov 16, 2022

Here's the backtrace:

Process 11873 stopped
* thread #41, stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
    frame #0: 0x00000001001fdeac highs-test`HighsSplitDeque::getCurrentHead(this=0x0000000000000000) const at HighsSplitDeque.h:481:49
   478
   479 	  int getOwnerId() const { return ownerData.ownerId; }
   480
-> 481 	  int getCurrentHead() const { return ownerData.head; }
   482
   483 	  HighsSplitDeque* getWorkerById(int id) const {
   484 	    return ownerData.workers[id].get();
Target 0: (highs-test) stopped.
(lldb) bt
* thread #41, stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
  * frame #0: 0x00000001001fdeac highs-test`HighsSplitDeque::getCurrentHead(this=0x0000000000000000) const at HighsSplitDeque.h:481:49
    frame #1: 0x00000001001fde7b highs-test`highs::parallel::TaskGroup::TaskGroup(this=0x0000700006e15c40) at HighsParallel.h:75:30
    frame #2: 0x00000001001fdc75 highs-test`highs::parallel::TaskGroup::TaskGroup(this=0x0000700006e15c40) at HighsParallel.h:73:15
    frame #3: 0x00000001000fd07c highs-test`HighsMipSolverData::evaluateRootNode(this=0x000000010980d800) at HighsMipSolverData.cpp:1198:30
    frame #4: 0x00000001000d7fce highs-test`HighsMipSolver::run(this=0x0000700006e169d8) at HighsMipSolver.cpp:122:15
    frame #5: 0x0000000100080c31 highs-test`Highs::callSolveMip(this=0x0000000109808c00) at Highs.cpp:2558:10
    frame #6: 0x000000010007cdff highs-test`Highs::run(this=0x0000000109808c00) at Highs.cpp:721:19
    frame #7: 0x00000001003de575 highs-test`::Highs_run(highs=0x0000000109808c00) at highs_c_api.cpp:177:69
    frame #8: 0x0000000100071b4a highs-test`highs::Model::try_solve::h0aaf7e2ee6519b00(self=Model @ 0x0000700006e17c08) at lib.rs:361:18
    frame #9: 0x0000000100071ac8 highs-test`highs::Model::solve::h26fb926768a44d01(self=Model @ 0x0000700006e17c58) at lib.rs:356:9
    frame #10: 0x0000000100009aa1 highs-test`highs_test::test_higs::he9df5fd31c5c97fc at main.rs:30:5
    frame #11: 0x000000010000ca28 highs-test`highs_test::main::_$u7b$$u7b$closure$u7d$$u7d$::hb5d764ecfe888792((null)=1) at main.rs:37:9

Looks like some thread-local work queue may not have been initialized properly.

@dirkschumacher
Copy link
Sponsor Contributor

What macOS version are you using?

@yongqli
Copy link
Author

yongqli commented Nov 24, 2023

This issue no longer seems to occur on the latest version of macOS. Thanks!

@yongqli yongqli closed this as completed Nov 24, 2023
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

No branches or pull requests

4 participants