From 9aba6c7cb0b32d4ff0b1dce651c9bcf11c7aa0b3 Mon Sep 17 00:00:00 2001 From: fikgol Date: Fri, 27 Nov 2020 11:32:08 +0800 Subject: [PATCH] [solver] Fix segfault fault when libloading open code --- cmd/miner_client/src/solver.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cmd/miner_client/src/solver.rs b/cmd/miner_client/src/solver.rs index 60ac36d1b1..e1769f3848 100644 --- a/cmd/miner_client/src/solver.rs +++ b/cmd/miner_client/src/solver.rs @@ -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; @@ -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 = 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::(SOLVER_CREATER)?; + Ok(call_ref()) }, }