From 8e26d4dbac8cd01985ec46fe38ac32e9395fb9cb Mon Sep 17 00:00:00 2001 From: hashmap Date: Thu, 12 Apr 2018 11:10:11 +0200 Subject: [PATCH] Fix Bus Error (core dumped) when validating fast sync txhashset (#956) This PR fixes #953 by introducing a lock for txhashet_write. It's not enough to synchronize access to in memory data, files also needs to be protected, so a general txhashset lock was introduced. --- chain/src/chain.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/chain/src/chain.rs b/chain/src/chain.rs index 631040d9b..fdb19aeca 100644 --- a/chain/src/chain.rs +++ b/chain/src/chain.rs @@ -127,6 +127,7 @@ pub struct Chain { head: Arc>, orphans: Arc, + txhashset_lock: Arc>, txhashset: Arc>, // POW verification function @@ -233,6 +234,7 @@ impl Chain { adapter: adapter, head: Arc::new(Mutex::new(head)), orphans: Arc::new(OrphanBlockPool::new()), + txhashset_lock: Arc::new(Mutex::new(false)), txhashset: Arc::new(RwLock::new(txhashset)), pow_verifier: pow_verifier, }) @@ -526,6 +528,7 @@ impl Chain { rewind_to_kernel: u64, txhashset_data: File, ) -> Result<(), Error> { + let _lock = self.txhashset_lock.lock().unwrap(); let head = self.head().unwrap(); let header_head = self.get_header_head().unwrap(); if header_head.height - head.height < global::cut_through_horizon() as u64 {