Skip to content

Commit

Permalink
[solver] Fix segfault fault when libloading open code
Browse files Browse the repository at this point in the history
  • Loading branch information
sanlee42 committed Nov 27, 2020
1 parent bf0020d commit 9aba6c7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cmd/miner_client/src/solver.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::cpu_solver::CpuSolver;
use crate::Solver;
use anyhow::Result;
use libloading::Library;
use starcoin_config::{MinerClientConfig, TimeService};
use std::sync::Arc;

Expand All @@ -19,8 +18,13 @@ pub fn create_solver(
Ok(Box::new(CpuSolver::new(config, ts)))
}
Some(path) => unsafe {
let lib = Library::new(path)?;
let call_ref: libloading::Symbol<CreateSolver> = lib.get(SOLVER_CREATER)?;
//Since this issue https://github.com/nagisa/rust_libloading/issues/41
#[cfg(target_os = "linux")]
let lib = libloading::os::unix::Library::open(Some(path), 0x2 | 0x1000)?;
#[cfg(not(target_os = "linux"))]
let lib = libloading::Library::new(path)?;
let call_ref = lib.get::<CreateSolver>(SOLVER_CREATER)?;

Ok(call_ref())
},
}
Expand Down

0 comments on commit 9aba6c7

Please sign in to comment.