diff options
| author | cyan <cyjan@mrcyjanek.net> | 2024-12-04 10:22:48 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-12-04 10:22:48 -0500 |
| commit | 2a38bf29618a8ce163f9d6f83b7ae86924752e32 (patch) | |
| tree | 585af02d98d0d042d7b873c5af96b80ddf776b08 /patches/monero/0003-store-crash-fix.patch | |
| parent | 40c1a1bda4b6f125c702f5a37ecc48a6ebec24b8 (diff) | |
cleanup patches (and other stuff) (#79)
* cleanup patches
* fix polyseed patch
* Fix iOS builds
* fix polyseed dependencies
* fix polyseed patch for macOS
* update ledger patch
* update wownero patches and version
* update checksums
* wip"
* update gitmodules
* update boost build script
* update build_single.sh
* vix verbosey_copy
* fix __clear_cache bug on wownero
* update randomwow
* migrate build system
* fix cross compilation issues
* some more build issue
* update polyseed
* cleanup cmakelists
* fix toolchain.cmake.in
* add ssp
* another attempt at building windows on CI
* fix package name
* migrate mirror to my own hosting
* change download mirror priority (fallback first)
* link ssp in monero module as well by using CMAKE_{C,CXX}_FLAGS
* fix android builds
* update polyseed source
* 13 -> trixie
* fix package name conflicts, update runner to sid
* update boost to 1_84_0, disable patch that's no longer needed
* switch to ubuntu:24.04
* add POLYSEED_STATIC to toolchain.cmake.in in order to properly link
* drop patches
* fixes to darwin
* link missing wowner-seed library
* a litte bit more of experiments
* build locale only on windows
* update iconv
* update definitions
* update ci builds
* update my progress
* ios fix, update depends, ci
* multithread build system
* fix android, mingw and linux build issues
* remove dependency check
* update Dockerfile to include pigz
* show a message when pigz is missing
* fix devcontainer mingw setup (missing ENV)
* update android build runner
* sailfishos dropped (you better go behave yourself and run actual linux programs)
* fiz pigz issues
* install llvm-ranlib for android
* fix iOS build issues
* fix dummy ledger patch
* fix macos and darwin
* fix macos ci
* fix macos build command
* install autoconf
* add automake
* add libtool
* macos fixes, wownero fixes, idk what else, please help me
* fix wownero iOS build
* Cleanup patches
* add try-catch into monero code
* fix error handling
* update checksums
Diffstat (limited to 'patches/monero/0003-store-crash-fix.patch')
| -rw-r--r-- | patches/monero/0003-store-crash-fix.patch | 208 |
1 files changed, 208 insertions, 0 deletions
diff --git a/patches/monero/0003-store-crash-fix.patch b/patches/monero/0003-store-crash-fix.patch new file mode 100644 index 0000000..225f0ab --- /dev/null +++ b/patches/monero/0003-store-crash-fix.patch @@ -0,0 +1,208 @@ +From b49bc52f3d3d1751dd65d4694e4f74b84b23f583 Mon Sep 17 00:00:00 2001 +From: Czarek Nakamoto <cyjan@mrcyjanek.net> +Date: Sat, 11 May 2024 16:25:10 +0200 +Subject: [PATCH 03/14] store crash fix + +Monero wallet crashes (sometimes) when it is syncing, +while the proper solution (that can be seen in feather) +is to not store wallet while it is being synced, this is not +acceptable for mobile wallets where OS can just come +and kill the wallet because it felt like it. + +This patch depends on the background-sync patch, but +to use it as a standalone fix grabbing the definition for the +LOCK_REFRESH macro should be enough. + +tobtoht suggested: +_say you want to store every 15 minutes during background sync. you stop the refresh every 15 minutes. then do something like this in the callback:_ + +``` +// Make sure this doesn't run in the refresh thread +onRefreshed() { + if (hasItBeen15MinutesSinceWeStored()) { + store(); + } + + if (shouldWeContinueRefreshing()) { + startRefresh(); + } +} +``` + +which works for crashes after the wallet is initially synced +but doesn't solve the issue for wallet that are syncing (it +would just wait for it to finish before actually storing). + +Also imo store() functin should store the wallet, no matter +the current state. +--- + src/wallet/api/wallet.cpp | 25 ++++++++++++------------- + src/wallet/api/wallet.h | 1 - + src/wallet/wallet2.cpp | 11 ++++++++++- + src/wallet/wallet2.h | 3 +++ + 4 files changed, 25 insertions(+), 15 deletions(-) + +diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp +index e9f76f4..0d85cf3 100644 +--- a/src/wallet/api/wallet.cpp ++++ b/src/wallet/api/wallet.cpp +@@ -55,8 +55,8 @@ using namespace cryptonote; + #define MONERO_DEFAULT_LOG_CATEGORY "WalletAPI" + + #define LOCK_REFRESH() \ +- bool refresh_enabled = m_refreshEnabled; \ +- m_refreshEnabled = false; \ ++ bool refresh_enabled = m_wallet->get_refresh_enabled(); \ ++ m_wallet->set_refresh_enabled(false); \ + m_wallet->stop(); \ + m_refreshCV.notify_one(); \ + boost::mutex::scoped_lock lock(m_refreshMutex); \ +@@ -466,7 +466,7 @@ WalletImpl::WalletImpl(NetworkType nettype, uint64_t kdf_rounds) + m_wallet2Callback.reset(new Wallet2CallbackImpl(this)); + m_wallet->callback(m_wallet2Callback.get()); + m_refreshThreadDone = false; +- m_refreshEnabled = false; ++ m_wallet->set_refresh_enabled(false); + m_addressBook.reset(new AddressBookImpl(this)); + m_subaddress.reset(new SubaddressImpl(this)); + m_subaddressAccount.reset(new SubaddressAccountImpl(this)); +@@ -962,6 +962,7 @@ void WalletImpl::stop() + bool WalletImpl::store(const std::string &path) + { + clearStatus(); ++ LOCK_REFRESH(); + try { + if (path.empty()) { + m_wallet->store(); +@@ -2448,10 +2449,10 @@ void WalletImpl::refreshThreadFunc() + } + + LOG_PRINT_L3(__FUNCTION__ << ": refresh lock acquired..."); +- LOG_PRINT_L3(__FUNCTION__ << ": m_refreshEnabled: " << m_refreshEnabled); ++ LOG_PRINT_L3(__FUNCTION__ << ": m_refreshEnabled: " << m_wallet->get_refresh_enabled()); + LOG_PRINT_L3(__FUNCTION__ << ": m_status: " << status()); + LOG_PRINT_L3(__FUNCTION__ << ": m_refreshShouldRescan: " << m_refreshShouldRescan); +- if (m_refreshEnabled) { ++ if (m_wallet->get_refresh_enabled()) { + LOG_PRINT_L3(__FUNCTION__ << ": refreshing..."); + doRefresh(); + } +@@ -2481,12 +2482,12 @@ void WalletImpl::doRefresh() + } + m_wallet->find_and_save_rings(false); + } else { +- LOG_PRINT_L3(__FUNCTION__ << ": skipping refresh - daemon is not synced"); ++ LOG_PRINT_L3(__FUNCTION__ << ": skipping refresh - daemon is not synced"); + } + } catch (const std::exception &e) { + setStatusError(e.what()); + break; +- }while(!rescan && (rescan=m_refreshShouldRescan.exchange(false))); // repeat if not rescanned and rescan was requested ++ }while(m_wallet->get_refresh_enabled() && !rescan && (rescan=m_refreshShouldRescan.exchange(false))); // repeat if not rescanned and rescan was requested + + if (m_wallet2Callback->getListener()) { + m_wallet2Callback->getListener()->refreshed(); +@@ -2496,9 +2497,9 @@ void WalletImpl::doRefresh() + + void WalletImpl::startRefresh() + { +- if (!m_refreshEnabled) { ++ if (!m_wallet->get_refresh_enabled()) { + LOG_PRINT_L2(__FUNCTION__ << ": refresh started/resumed..."); +- m_refreshEnabled = true; ++ m_wallet->set_refresh_enabled(true); + m_refreshCV.notify_one(); + } + } +@@ -2508,7 +2509,7 @@ void WalletImpl::startRefresh() + void WalletImpl::stopRefresh() + { + if (!m_refreshThreadDone) { +- m_refreshEnabled = false; ++ m_wallet->set_refresh_enabled(false); + m_refreshThreadDone = true; + m_refreshCV.notify_one(); + m_refreshThread.join(); +@@ -2519,9 +2520,7 @@ void WalletImpl::pauseRefresh() + { + LOG_PRINT_L2(__FUNCTION__ << ": refresh paused..."); + // TODO synchronize access +- if (!m_refreshThreadDone) { +- m_refreshEnabled = false; +- } ++ m_wallet->set_refresh_enabled(false); + } + + +diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h +index 1f199a7..ac7ce2f 100644 +--- a/src/wallet/api/wallet.h ++++ b/src/wallet/api/wallet.h +@@ -273,7 +273,6 @@ private: + std::unique_ptr<SubaddressAccountImpl> m_subaddressAccount; + + // multi-threaded refresh stuff +- std::atomic<bool> m_refreshEnabled; + std::atomic<bool> m_refreshThreadDone; + std::atomic<int> m_refreshIntervalMillis; + std::atomic<bool> m_refreshShouldRescan; +diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp +index 8146014..7913d55 100644 +--- a/src/wallet/wallet2.cpp ++++ b/src/wallet/wallet2.cpp +@@ -1192,6 +1192,7 @@ wallet2::wallet2(network_type nettype, uint64_t kdf_rounds, bool unattended, std + m_upper_transaction_weight_limit(0), + m_run(true), + m_callback(0), ++ m_refreshEnabled(false), + m_trusted_daemon(false), + m_nettype(nettype), + m_multisig_rounds_passed(0), +@@ -1404,6 +1405,14 @@ bool wallet2::set_daemon(std::string daemon_address, boost::optional<epee::net_u + return ret; + } + //---------------------------------------------------------------------------------------------------- ++bool wallet2::get_refresh_enabled() { ++ return m_refreshEnabled; ++} ++//---------------------------------------------------------------------------------------------------- ++void wallet2::set_refresh_enabled(bool val) { ++ m_refreshEnabled = val; ++} ++//---------------------------------------------------------------------------------------------------- + bool wallet2::set_proxy(const std::string &address) + { + return m_http_client->set_proxy(address); +@@ -4096,7 +4105,7 @@ void wallet2::refresh(bool trusted_daemon, uint64_t start_height, uint64_t & blo + // infer when we get an incoming output + + bool first = true, last = false; +- while(m_run.load(std::memory_order_relaxed) && blocks_fetched < max_blocks) ++ while(m_run.load(std::memory_order_relaxed) && blocks_fetched < max_blocks && m_refreshEnabled) + { + uint64_t next_blocks_start_height; + std::vector<cryptonote::block_complete_entry> next_blocks; +diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h +index b1dc4f7..a050286 100644 +--- a/src/wallet/wallet2.h ++++ b/src/wallet/wallet2.h +@@ -1071,6 +1071,8 @@ private: + boost::optional<epee::net_utils::http::login> daemon_login = boost::none, bool trusted_daemon = true, + epee::net_utils::ssl_options_t ssl_options = epee::net_utils::ssl_support_t::e_ssl_support_autodetect); + bool set_proxy(const std::string &address); ++ bool get_refresh_enabled(); ++ void set_refresh_enabled(bool val); + + void stop() { m_run.store(false, std::memory_order_relaxed); m_message_store.stop(); } + +@@ -1981,6 +1983,7 @@ private: + + boost::recursive_mutex m_daemon_rpc_mutex; + ++ bool m_refreshEnabled; + bool m_trusted_daemon; + i_wallet2_callback* m_callback; + hw::device::device_type m_key_device_type; +-- +2.39.5 (Apple Git-154) + |
