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

zpiv up to date precomputing validation + witness calculation height #1

Conversation

furszy
Copy link

@furszy furszy commented Mar 27, 2019

No description provided.

@furszy furszy closed this Mar 30, 2019
Fuzzbawls pushed a commit that referenced this pull request Mar 18, 2020
…filterAcceptsRow

359f70e [GUI] Explicit cast from quint32 to bool in filterAcceptsRow (random-zebra)

Pull request description:

  This is a (hopefully definitive) fix for a strange segfault I was consistently having on testnet with the GUI wallet (during the loading of the stake charts), with the following stacktrace
  ```
  #0  0x00007ffff58363bb in  ()
      at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
  #1  0x00007ffff583b25d in  ()
      at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
  PIVX-Project#2  0x00007ffff583b932 in  ()
      at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
  PIVX-Project#3  0x00007ffff583bca9 in  ()
      at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
  PIVX-Project#4  0x00007ffff583c50a in QSortFilterProxyModel::invalidateFilter() ()
      at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
  PIVX-Project#5  0x00005555556aa809 in DashboardWidget::updateStakeFilter() (this=this@entry=0x5555577817d0) at qt/pivx/dashboardwidget.cpp:480
  PIVX-Project#6  0x00005555556ac736 in DashboardWidget::getAmountBy() (this=this@entry=0x5555577817d0) at qt/pivx/dashboardwidget.cpp:503
  PIVX-Project#7  0x00005555556ad1a1 in DashboardWidget::loadChartData(bool) (this=this@entry=0x5555577817d0, withMonthNames=false)
      at qt/pivx/dashboardwidget.cpp:556
  PIVX-Project#8  0x00005555556ad703 in DashboardWidget::run(int) (this=0x5555577817d0, type=<optimized out>) at qt/pivx/dashboardwidget.cpp:812
  PIVX-Project#9  0x00005555557641d4 in Worker::process() (this=0x5555576314c0)
      at qt/pivx/loadingdialog.cpp:12
  PIVX-Project#10 0x00007ffff56932b2 in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
  PIVX-Project#11 0x00007ffff569617d in  () at /usr/lib/x86_64-linux-gnu/libQt5Core.so.5
  PIVX-Project#12 0x00007ffff4ae36db in start_thread (arg=0x7ffe61ffb700) at pthread_create.c:463
  PIVX-Project#13 0x00007ffff2c9e88f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95
  ```

  Explicit the cast to bool when checking the transaction type in `TransactionFilterProxy::filterAcceptsRow`.

ACKs for top commit:
  furszy:
    detective work 👍 , utACK 359f70e.
  Fuzzbawls:
    utACK 359f70e then

Tree-SHA512: f1481a0545fb1ebe62b28232f9257e6c52306ff15dd1dcefc29d4eeb3dd25b7231d48416cad528e720fb68aa192b089e14bfc8ee92e55406ea02fc777f552b15
Fuzzbawls added a commit that referenced this pull request Jul 9, 2020
0c40829872 Remove redundant PROJECT_SOURCE_DIR usage from CMake config.
5abdf4c019 Fix installed target definition.
cf4d9ab23d Test CMake installation on Travis.
95d0ba1cb0 Renamed local variable in DBImpl::Write.
657ba51429 Added return in Version::Get::State::Match to quiet warning.
370d532a00 Using CMake's check_cxx_compiler_flag to check support for -Wthread-safety.
45ee61579c Update Travis CI configuration.
60db170a43 Fix tsan problem in env_test.
21304d41f7 Merge pull request PIVX-Project#698 from neal-zhu:master
5e921896ee drop fileds in State that are duplicates of fileds in Saver and fix typo
53e280b568 Simplify unlocking in DeleteObsoleteFiles.
046216a7ca Add "leveldb" subdirectory to public include paths.
9ee91ac747 Ending sentences with periods in README.md.
e0d5f83a4f Align EnvPosix and EnvWindows.
69061b464a Disable exceptions and RTTI in CMake configuration.
107a75b62c cache Saver in State object
76ca116276 fix bug(uninitialized options pointer in State)
f668239bb2 remove TODO in Version::ForEachOverlapping
177cd08629 format
8fa7a937ee fix bug
6a90bb91ee use ForEachOverlapping to impl Get
4cb80b7ddc Merge pull request PIVX-Project#386 from ivanabc:master
72a38ff7f2 Replace "> >" with ">>"
863f185970 unsigned char -> uint8_t
a3b71c1ff6 Use GCC 9 on Travis CI
ae49533210 Add explicit typecasts to avoid compiler warning.
63d5315e1c Merge branch 'master' into master
c00e177f36 Guard DBImpl::versions_ by mutex_.
1d0b101165 Converted two for-loops to while-loops.
28e6d238be Switch to using C++ 11 override specifier.
85cd40d108 Added unit test for InternalKey::DecodeFrom with empty string.
1aae5c9f29 Merge pull request PIVX-Project#411 from proller:assert1
b7b86baec9 Using std::ostringstream in key DebugString.
3e6c000e18 Merge pull request PIVX-Project#457 from jellor:patch-2
1d94fe2f4d Merge branch 'master' into patch-2
27dc99fb26 Fix EnvPosix tests on Travis CI.
9521545b06 Formatting changes for prior O_CLOEXEC fix.
900f7d37eb Merge pull request PIVX-Project#624 from adam-azarchs:master
a7528a5d2b Clean up util/coding.{h,cc}.
142035edd4 Initialize Stats::start_ before first use in Stats::Start().
e22b1cec6e Merge pull request PIVX-Project#365 from allangj:c-strict-prototypes
cd1ec032cd Add argument definition for void c functions.
4bd052d7e8 Consolidate benchmark code to benchmarks/.
506b1722ef Convert missed virtual -> override in db_test.cc.
24424a1ef2 Style cleanup.
9a56c49ed4 Merge pull request PIVX-Project#679 from smartxworks:optimize-readseq
abf441b657 Merge pull request PIVX-Project#278 from wankai:master
78b39d68c1 Bump the version number from 1.21 to 1.22.
9bd23c7676 Correct class/structure declaration order.
c784d63b93 Moved port/README to port/README.md.
297e66afc1 Format all files IAW the Google C++ Style Guide.
3724030179 Update Travis CI configuration.
d3d1c8a0f4 don't check current key in DBIter::Next()
3dc9202f78 [leveldb] Specifically export the WriteBatch::Handler inner class for Windows link
2ccb45c33a Check for possibly invalid offset in test.
7b11745190 Changed Windows specific highlighting from bash to cmd.
2f008ac19e Initialize class members to default values in constructors.
ffabb1ae86 Merge pull request PIVX-Project#665 from cheng-chang:coding
7da571cf2b Merge pull request PIVX-Project#669 from pavel-pimenov:fix-readme-windows-mkdir
df4a323aaf Merge pull request PIVX-Project#472 from zhoudayang:patch-1
5a2a472741 Fixed missing std namespaces and make_unique.
08e771901f Simplify issue320_test.
65e86f75ea Fix formatting of recent snapshot compaction fix.
7711e76766 Merge pull request PIVX-Project#339 from richcole-at-amazon:master
71ed7c401e Fixed typo in comment in version_set.h.
09fa8868db Align version/soversion CMake setup closer with other repositories.
20fb601aa9 Fix snapshot compaction bug
37300aa54b Restore soname versioning with CMake build
952be04df6 Fix mkdir (windows)
56178ddaf4 Update the version to 1.21 in preparation for a new release.
35619d248d Project import generated by Copybara.
416344de2f leveldb: Register in copybara whitelist.
da94ac67e9 leveldb: Minor cleanup in ports.
bd24b96306 leveldb: Silence unused argument warnings in MSVC.
6188a54ce9 leveldb: Add tests for empty keys and values.
cf1b5f4732 Remove unnecessary bit operation.
7035af5fc3 Two small fixes for the Windows implementation (PIVX-Project#661)
6571279d6d fix a typo in the comment of skiplist_test.cc (PIVX-Project#664)
15e2278966 Use override consistently in leveldb::test::ErrorEnv.
ea49b27d06 Switch corruption_test to use InMemEnv.
ce399ac28a Always copy bytes to scratch buffer when reading w/MemEnv.
201f77d137 Inline defaults in options.
9ce30510d4 Deleted dangling reference to deleted atomic_pointer.h.
7d8e41e49b leveldb: Replace AtomicPointer with std::atomic.
dd906262fd Make InMemoryEnv more consistent with filesystem based Env's.
cf1d1ab255 leveldb: Remove unused file port/win/stdint.h.
a20508dc6a Fix typo (PIVX-Project#565)
04470825ac Add AppVeyor (Windows CI) badge to README.
ed76289b25 Align windows_logger with posix_logger.
808e59ec6a Improve CI configuration.
c69d33b0ec Added native support for Windows.
75fceae700 Add O_CLOEXEC to open calls.
fe4494804f leveldb: Make WriteBatch::ApproximateSize() const.
296de8d5b8 leveldb: Fix PosixWritableFile::Sync() on Apple systems.
b70493ca85 Fix fdatasync() feature detection in opensource build.
af7abf06ea Add back space to POSIX Logger.
58d70545af Update Travis CI configuration.
1cb3840881 Clean up env_posix.cc.
a7dc502e9f Rework once initialization in env_posix.cc.
c43565dd39 C++11 cleanup for util/mutexlock.h.
0145a94ab6 Update .gitignore.
73d5834ece Rework threading in env_posix.cc.
05709fb43e Remove InitOnce from the port API.
bb88f25115 Clean up PosixWritableFile in env_posix.cc.
7b945f2003 Clean up posix_logger.h.
89af27bde5 Remove ssize_t from code that is not POSIX-specific.
03064cbbb2 Simplify Limiter in env_posix.cc.
9b44da73d9 Clarify comments for leveldb::Env file reading methods.
0ef2310f67 Remove GCC on OSX from the Travis CI matrix.
16a2b8bb3a Expose WriteBatch::Append in the C API.
f7b0e1d901 Expose WriteBatch::Append().
6caf73ad9d Clean up Iterator.
6a6bdafcf1 Corrected typo in docs: "cache" to "block_cache".
1868398150 Clean up SnapshotImpl.
e7840de9f3 Fix documentation for log file growth.
bc23e00f95 Update default log file size in doc.
4de9594f6f Add move constructor to Status.
d177a0263c Replace port_posix with port_stdcxx.
14cce848e7 Fix sign mismatch warnings in GCC.
8046a51b21 Add forgotten <limits> header to util/logging.cc.
a0008deb67 Reimplement ConsumeDecimalNumber.
1f7dd5d5f6 Add tests for ConsumeDecimalNumber.
1cc8b10b82 Document the building process.
09217fd067 Replace NULL with nullptr in C++ files.
6a3b915166 Remove PLATFORM_IS_LITTLE_ENDIAN from port/posix.h.
260655b4c2 Define LEVELDB_HAS_PORT_CONFIG_H for old compilers.
6fa4566670 Rename CMake project / targets from Leveldb to leveldb.
0db30413a4 leveldb: Add more thread safety annotations.
04f39105c5 Take <atomic> for granted in port/atomic_pointer.h.
74f032ff6f leveldb: Require C++11.
8e75db8623 Remove build configuration for make.
df9a841a4f Add export.h to CMakeLists.txt
50fbc87e8c Replace SIZE_MAX with std::numeric_limits.
739c25100e Add CMake build support.
0fa5a4f7b1 Extend thread safety annotations.
8143c12f3f Fix includes in util/testharness.h.
aece2068d7 Remove extern from function declarations.
ddab751002 Add tests for {Old}InfoLogFileName().
7fd7c00721 Remove unused function ExtractValueType.
594cc987af Bypass OSMemoryBarrier() warning on Mac.
49f35d3fc9 leveldb: Update Travis CI configuration for open source build.
623d014a54 Expose Env::GetTempDirectory() for use in C test.
8c8024ea33 Switch HAVE_ library detection macros to 0/1.
41172a2401 Enable thread safety annotations in open source version.
47cb9e2a21 Add leveldb_options_set_max_file_size to the C API.
b5d4a22e64 Fixed style guide link in CONTRIBUTING.md
3da4d8b989 Deleted unused assignments in Reader.
0509414f85 leveldb::DestroyDB will now delete empty directories.
23162ca1c6 Fix typo (forgotten reference operator) in test.
5c39524f36 Replace SSE-optimized CRC32C in POSIX port with external library.
ca216e493f leveldb: Rename SNAPPY to HAVE_SNAPPY.
25767d066c leveldb: Remove *_unlocked feature detection from POSIX port.
4a7e7f50dc Add LEVELDB_EXPORT macro to export public symbols.
542590d2a8 leveldb: Include <algorithm> in util/env_test.cc.
8ae7998aab Fix FD leak in POSIX Env.
d9a9e02edf leveldb: Add tests for CL 170769101.
4447f9cace Remove handling for unused LRUHandle representation special case.
2372ac574f Fix file writing bug in CL 170738066.
1c75e88055 Fix use of uninitialized value in LRUHandle.
7e12c00ecf Fix issue 474: a race between the f*_unlocked() STDIO calls in env_posix.cc and concurrent application calls to fflush(NULL).
bcd9a8ea4a Use portable CRC32C from google/crc32c.
ea0a7586b8 Remove confusing and unnecessary if.
141e767135 Simplify Table::Open() flow and remove a delete call.
09a3c8e741 Switched variable type from int to uint64_t in ConsumeDecimalNumber.
2964b803b8 leveldb: Fix alignment code in SSE4.2-optimized CRC32C.
02f43c0fcd Remove dead code.
0b402e96a7 Use __APPLE__ instead of OS_MACOS. The former is compiler-provided.
8415f00eee leveldb: Report missing CURRENT manifest file as database corruption.
69e2bd224b LevelDB: Add WriteBatch::ApproximateSize().
471f0b84ec fix comment
5b817400a0 fix comment
7d060117fa broken db: fix assertion in leveldb::InternalKey::Encode, mark base as corrupt
2883fcd849 set const property
e5f0a51fa4 reduce lock's range in DeleteObsoleteFiles
dd598676cd block_builder header file dependency fixed
REVERT: 64052c7 Merge PIVX-Project#15: Add filename to corruption errors
REVERT: 135ed0f Add filename to corruption errors
REVERT: c521b3a Merge PIVX-Project#11: fixup define checks. Cleans up some oopses from PIVX-Project#5.
REVERT: 8b1cd37 fixup define checks. Cleans up some oopses from PIVX-Project#5.
REVERT: 6b1508d Merge PIVX-Project#6: Fixes typo
REVERT: fceb805 Merge PIVX-Project#10: Clean up compile-time warnings (gcc 7.1)
REVERT: 0ec2a34 Clean up compile-time warnings (gcc 7.1)
REVERT: d4c268a Merge PIVX-Project#5: Move helper functions out of sse4.2 object
REVERT: 8d4eb08 Add HasAcceleratedCRC32C to port_win.h
REVERT: 77cfbfd crc32: move helper functions out of port_posix_sse.cc
REVERT: 4c1e9e0 silence compiler warnings about uninitialized variables
REVERT: 4953164 Merge PIVX-Project#2: Prefer std::atomic over MemoryBarrier
REVERT: 2953978 Fixes typo
REVERT: f134284 Merge #1: Merge upstream LevelDB 1.20
REVERT: 196962f Add AcceleratedCRC32C to port_win.h
REVERT: ba8a445 Prefer std::atomic over MemoryBarrier
REVERT: 1bdf1c3 Merge upstream LevelDB v1.20
REVERT: d31721e Merge PIVX-Project#17: Fixed file sharing errors
REVERT: fecd449 Fixed file sharing error in Win32Env::GetFileSize(), Win32SequentialFile::_Init(), Win32RandomAccessFile::_Init() Fixed error checking in Win32SequentialFile::_Init()
REVERT: 5b7510f Merge PIVX-Project#14: Merge upstream LevelDB 1.19
REVERT: 0d969fd Merge PIVX-Project#16: [LevelDB] Do no crash if filesystem can't fsync
REVERT: c8c029b [LevelDB] Do no crash if filesystem can't fsync
REVERT: a31c8aa Add NewAppendableFile for win32 environment
REVERT: d40bc3f Merge PIVX-Project#13: Typo
REVERT: ebbd772 Typo
REVERT: 1913d71 Merge upstream LevelDB 1.19
REVERT: 20ca81f Merge pull request PIVX-Project#9
REVERT: 7aa105e leveldb: Win32WritableFile without memory mapping
REVERT: 7d41e6f Merge upstream LevelDB 1.18
REVERT: 42dcc7e Merge upstream LevelDB 1.17.
REVERT: e991315 Merge upstream LevelDB 1.15.
REVERT: 02ac9f1 Merge upstream LevelDB 1.14.
REVERT: 936b461 Merge upstream LevelDB 1.13.
REVERT: be1b0ff On Mac OS X fsync does not guarantee write to disk. Use fcntl F_FULLFSYNC instead.
REVERT: a02ddf9 Added GNU/kFreeBSD kernel name (TARGET_OS)
REVERT: 8487468 CondVar::SignalAll was broken, leading to deadlocks on Windows builds. http://code.google.com/p/leveldb/issues/detail?id=149
REVERT: f6d84d1 Allow files to be opened for reading multiple times
REVERT: cb8e3f7 Checking whether closing succeeds
REVERT: d5317e8 Print actual Win32 error that occurred on file creation failure.
REVERT: 907f308 Port leveldb to MinGW32
REVERT: 9def2bf Mingw support for Windows LevelDB port
REVERT: 0a7b074 Pre-Vista leveldb::port::InitOnce implementation
REVERT: 31a2b09 Native Windows LevelDB port
REVERT: 058a035 Remove Snappy support

git-subtree-dir: src/leveldb
git-subtree-split: 0c40829872a9f00f38e11dc370ff8adb3e19f25b
Fuzzbawls pushed a commit that referenced this pull request Mar 4, 2021
4749d52 [Refactoring][BUG] Unchecked LoadGenesisBlock return value (random-zebra)
43cc880 Fix segfault when shutting down before fully loading (Matt Corallo)
5f1f014 Order chainstate init more logically. (random-zebra)
9b87537 More user-friendly error message if UTXO DB runs ahead of block DB (Matt Corallo)
9bcc942 Fix some LoadChainTip-related init-order bugs. (random-zebra)

Pull request description:

  Had this segfault when trying to shut down the wallet before the coins cache is loaded.
  ```
  CCoinsViewCache::DynamicMemoryUsage (this=0x0) at coins.cpp:60
  60	    return memusage::DynamicUsage(cacheCoins) +
  (gdb) bt
  #0  0x0000555555bb8b44 in CCoinsViewCache::DynamicMemoryUsage() const (this=0x0) at coins.cpp:60
  #1  0x0000555555996bc1 in FlushStateToDisk(CValidationState&, FlushStateMode) (state=..., mode=mode@entry=FLUSH_STATE_ALWAYS) at validation.cpp:1730
  PIVX-Project#2  0x0000555555997540 in FlushStateToDisk() () at validation.cpp:1806
  PIVX-Project#3  0x000055555582516c in PrepareShutdown() () at init.cpp:266
  PIVX-Project#4  0x0000555555826005 in Shutdown() () at init.cpp:339
  ```

  This is due to a bug introduced in 64c525b (we should null-check `pcoinsTip` before calling `FlushStateToDisk` at line 266, same as we do at line 283).

  Upstream fixed it in bitcoin#10758 among few other things.
  Backported here without ff3a219 (as we don't have `RewindBlockIndex` or `reindex-chainstate` yet).

ACKs for top commit:
  Fuzzbawls:
    ACK 4749d52
  furszy:
    ACK 4749d52 and merging..

Tree-SHA512: 23f27c4a9422a72794054698313259f89ad22a58dba2809901653e08c964c73e4eaeab872ada42380e76eb46ddd7e57f08b65f22812c791d0c2b274e5f0202a7
Fuzzbawls added a commit that referenced this pull request Jun 16, 2021
b5ef9be675 Merge #1: Merge changes from upstream
9e7f512430 Merge remote-tracking branch 'origin/master' into bitcoin-fork
1f85030246 Add support for ARM64 darwin (PIVX-Project#43)
3bb959c982 Remove unnecessary reinterpret_cast (PIVX-Project#42)
2e97ab26b1 Fix (unused) ReadUint64LE for BE machines (PIVX-Project#41)
47b40d2209 Bump dependencies. (PIVX-Project#40)
ba74185625 Move CI to Visual Studio 2019.
efa301a7e5 Allow different C/C++ standards when this is used as a subproject.
cc6d71465e CMake: Use configure_package_config_file()

git-subtree-dir: src/crc32c
git-subtree-split: b5ef9be6755a2e61e2988bb238f13d1c0ee1fa0a
Fuzzbawls added a commit that referenced this pull request May 4, 2024
f9a6ebd fix: solve data race by making nTimeBestReceived atomic (ale)
4331c30 refactor: move nTimeBestReceived to CWallet (ale)

Pull request description:

  First commit is a small refactor:  the global variable `nTimeBestReceived` is now a private member of the `CWallet` class, as it was used only there.

  Second commit: fix the following data race by making `nTimeBestReceived` atomic

  ```
  WARNING: ThreadSanitizer: data race (pid=18270)
    Write of size 8 at 0x7b6800000ed8 by thread T16:
      #0 CWallet::UpdatedBlockTip(CBlockIndex const*, CBlockIndex const*, bool) wallet/wallet.cpp:2094 (pivxd+0x5058c9)
      #1 void std::__invoke_impl<void, void (CValidationInterface::*&)(CBlockIndex const*, CBlockIndex const*, bool), CValidationInterface*&, CBlockIndex const*, CBlockIndex const*, bool>(std::__invoke_memfun_deref, void (CValidationInterface::*&)(CBlockIndex const*, CBlockIndex const*, bool), CValidationInterface*&, CBlockIndex const*&&, CBlockIndex const*&&, bool&&) /usr/include/c++/12/bits/invoke.h:74 (pivxd+0x2ee1c0)
      PIVX-Project#2 std::__invoke_result<void (CValidationInterface::*&)(CBlockIndex const*, CBlockIndex const*, bool), CValidationInterface*&, CBlockIndex const*, CBlockIndex const*, bool>::type std::__invoke<void (CValidationInterface::*&)(CBlockIndex const*, CBlockIndex const*, bool), CValidationInterface*&, CBlockIndex const*, CBlockIndex const*, bool>(void (CValidationInterface::*&)(CBlockIndex const*, CBlockIndex const*, bool), CValidationInterface*&, CBlockIndex const*&&, CBlockIndex const*&&, bool&&) /usr/include/c++/12/bits/invoke.h:96 (pivxd+0x2ee25a)
      PIVX-Project#3 void std::_Bind<void (CValidationInterface::*(CValidationInterface*, std::_Placeholder<1>, std::_Placeholder<2>, std::_Placeholder<3>))(CBlockIndex const*, CBlockIndex const*, bool)>::__call<void, CBlockIndex const*&&, CBlockIndex const*&&, bool&&, 0ul, 1ul, 2ul, 3ul>(std::tuple<CBlockIndex const*&&, CBlockIndex const*&&, bool&&>&&, std::_Index_tuple<0ul, 1ul, 2ul, 3ul>) /usr/include/c++/12/functional:484 (pivxd+0x2ee25a)
      ...

    Previous read of size 8 at 0x7b6800000ed8 by thread T35 (mutexes: write M134298, write M132880):
      #0 CWallet::ResendWalletTransactions(CConnman*) wallet/wallet.cpp:2065 (pivxd+0x515b25)
      #1 void std::__invoke_impl<void, void (CValidationInterface::*&)(CConnman*), CValidationInterface*&, CConnman*>(std::__invoke_memfun_deref, void (CValidationInterface::*&)(CConnman*), CValidationInterface*&, CConnman*&&) /usr/include/c++/12/bits/invoke.h:74 (pivxd+0x2eef45)
      PIVX-Project#2 std::__invoke_result<void (CValidationInterface::*&)(CConnman*), CValidationInterface*&, CConnman*>::type std::__invoke<void (CValidationInterface::*&)(CConnman*), CValidationInterface*&, CConnman*>(void (CValidationInterface::*&)(CConnman*), CValidationInterface*&, CConnman*&&) /usr/include/c++/12/bits/invoke.h:96 (pivxd+0x2eefb9)
      PIVX-Project#3 void std::_Bind<void (CValidationInterface::*(CValidationInterface*, std::_Placeholder<1>))(CConnman*)>::__call<void, CConnman*&&, 0ul, 1ul>(std::tuple<CConnman*&&>&&, std::_Index_tuple<0ul, 1ul>) /usr/include/c++/12/functional:484 (pivxd+0x2eefb9)
      ...
  ```

ACKs for top commit: f9a6ebd
  Duddino:
    utACK f9a6ebd
  Liquid369:
    tACK f9a6ebd
  Fuzzbawls:
    ACK f9a6ebd

Tree-SHA512: c1de883956bf0958204b05c338831c27f694e6453e74b77e3347ae12a3cbd69df2fe1120bae3fca72dab14587c0c499c4f92d5c53943305855e66fc1275ab4fa
Fuzzbawls added a commit that referenced this pull request May 4, 2024
ddbd4b0 fix BlockStateCatcher data races (ale)
b01c3df let validationinterface take shared_ptr (ale)

Pull request description:

  first commit:
  Partially backport bitcoin PR bitcoin#18338 which introduce the functions
  `RegisterSharedValidationInterface` and `UnregisterSharedValidationInterface`.  See that PR why using normal pointers is problematic, and how `shared_ptr` solve the issue
  (In a few words the problem is that it can happen that the pointed memory is freed before all signals have been processed, while with shared pointer we are sure that  memory will be freed after the last signal is handled)

  second commit:
  Utilize the new functions to the validation interface `BlockStateCatcher`.  In order to keep everywhere the logic unchanged (Registering on creation and Unregistering when the object goes out of scope) I created the wrapper class `BlockStateCatcherWrapper` which contains a `shared_ptr` to `BlockStatecatcher`.

  Those two commits solve the following data race where a `BlockStateCatcher` pointer is dereferenced after the pointed memory is freed

  ```
  WARNING: ThreadSanitizer: data race on vptr (ctor/dtor vs virtual call) (pid=6423)
    Write of size 8 at 0x7fc3d7c2d570 by thread T20:
      #0 CValidationInterface::~CValidationInterface() validationinterface.h:75 (pivxd+0xeacac)
      #1 BlockStateCatcher::~BlockStateCatcher() util/blockstatecatcher.h:23 (pivxd+0xeacac)
      PIVX-Project#2 generateBlocks(Consensus::Params const&, CWallet*, bool, int, int, int, CScript*) rpc/mining.cpp:78 (pivxd+0x1c1a98)
      PIVX-Project#3 generate(JSONRPCRequest const&) rpc/mining.cpp:140 (pivxd+0x1c2215)
      ...

    Previous read of size 8 at 0x7fc3d7c2d570 by thread T35 (mutexes: write M133270, write M132847):
      #0 void std::__invoke_impl<void, void (CValidationInterface::*&)(CConnman*), CValidationInterface*&, CConnman*>(std::__invoke_memfun_deref, void (CValidationInterface::*&)(CConnman*), CValidationInterface*&, CConnman*&&) /usr/include/c++/12/bits/invoke.h:74 (pivxd+0x2eef14)
      #1 std::__invoke_result<void (CValidationInterface::*&)(CConnman*), CValidationInterface*&, CConnman*>::type std::__invoke<void (CValidationInterface::*&)(CConnman*), CValidationInterface*&, CConnman*>(void (CValidationInterface::*&)(CConnman*), CValidationInterface*&, CConnman*&&) /usr/include/c++/12/bits/invoke.h:96 (pivxd+0x2eefbb)
      PIVX-Project#2 void std::_Bind<void (CValidationInterface::*(CValidationInterface*, std::_Placeholder<1>))(CConnman*)>::__call<void, CConnman*&&, 0ul, 1ul>(std::tuple<CConnman*&&>&&, std::_Index_tuple<0ul, 1ul>) /usr/include/c++/12/functional:484 (pivxd+0x2eefbb)
      ...
     ```

ACKs for top commit: ddbd4b0
  Duddino:
    utACK ddbd4b0
  Liquid369:
    tACK ddbd4b0

Tree-SHA512: 94d55effc11f14f755f27c30ef1b6801a235bc314cc34312ebb14b75525824d3b11bb7812389d9977c30a0929d62fb745bd5c1a15249708014bd573132a5e55c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant