James O'Beirne
8722e54e56
threads: add thread names to deadlock debugging message
...
Also refactor CLockLocation to use an initialization list.
2019-04-29 13:51:59 -04:00
Akio Nakamura
b09dab0f2d
Prevent mutex lock fail even if --enable-debug
...
This PR intends to resolve #15227 .
"configure --debug-enabled" enables "#ifdef DEBUG_LOCKORDER".
Then "lockdata" (in sync.cpp) will be initialized same as other
static objects.
But unfortunately, lockdata.push_lock() was called before its
initialization (via initializing signatureCache which is declared
in script/sigcache.cpp) on macOS.
This PR apply the "Construct On First Use Idiom" to "lockdata"
to prevent it.
2019-01-25 13:21:59 +09:00
Jim Posen
2068f089c8
scripted-diff: Move util files to separate directory.
...
-BEGIN VERIFY SCRIPT-
mkdir -p src/util
git mv src/util.h src/util/system.h
git mv src/util.cpp src/util/system.cpp
git mv src/utilmemory.h src/util/memory.h
git mv src/utilmoneystr.h src/util/moneystr.h
git mv src/utilmoneystr.cpp src/util/moneystr.cpp
git mv src/utilstrencodings.h src/util/strencodings.h
git mv src/utilstrencodings.cpp src/util/strencodings.cpp
git mv src/utiltime.h src/util/time.h
git mv src/utiltime.cpp src/util/time.cpp
sed -i 's/<util\.h>/<util\/system\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')
sed -i 's/<utilmemory\.h>/<util\/memory\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')
sed -i 's/<utilmoneystr\.h>/<util\/moneystr\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')
sed -i 's/<utilstrencodings\.h>/<util\/strencodings\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')
sed -i 's/<utiltime\.h>/<util\/time\.h>/g' $(git ls-files 'src/*.h' 'src/*.cpp')
sed -i 's/BITCOIN_UTIL_H/BITCOIN_UTIL_SYSTEM_H/g' src/util/system.h
sed -i 's/BITCOIN_UTILMEMORY_H/BITCOIN_UTIL_MEMORY_H/g' src/util/memory.h
sed -i 's/BITCOIN_UTILMONEYSTR_H/BITCOIN_UTIL_MONEYSTR_H/g' src/util/moneystr.h
sed -i 's/BITCOIN_UTILSTRENCODINGS_H/BITCOIN_UTIL_STRENCODINGS_H/g' src/util/strencodings.h
sed -i 's/BITCOIN_UTILTIME_H/BITCOIN_UTIL_TIME_H/g' src/util/time.h
sed -i 's/ util\.\(h\|cpp\)/ util\/system\.\1/g' src/Makefile.am
sed -i 's/utilmemory\.\(h\|cpp\)/util\/memory\.\1/g' src/Makefile.am
sed -i 's/utilmoneystr\.\(h\|cpp\)/util\/moneystr\.\1/g' src/Makefile.am
sed -i 's/utilstrencodings\.\(h\|cpp\)/util\/strencodings\.\1/g' src/Makefile.am
sed -i 's/utiltime\.\(h\|cpp\)/util\/time\.\1/g' src/Makefile.am
sed -i 's/-> util ->/-> util\/system ->/' test/lint/lint-circular-dependencies.sh
sed -i 's/src\/util\.cpp/src\/util\/system\.cpp/g' test/lint/lint-format-strings.py test/lint/lint-locale-dependence.sh
sed -i 's/src\/utilmoneystr\.cpp/src\/util\/moneystr\.cpp/g' test/lint/lint-locale-dependence.sh
sed -i 's/src\/utilstrencodings\.\(h\|cpp\)/src\/util\/strencodings\.\1/g' test/lint/lint-locale-dependence.sh
sed -i 's/src\\utilstrencodings\.cpp/src\\util\\strencodings\.cpp/' build_msvc/libbitcoinconsensus/libbitcoinconsensus.vcxproj
-END VERIFY SCRIPT-
2018-11-04 22:46:07 -08:00
Wladimir J. van der Laan
385ad11040
Merge #11640 : Make LOCK, LOCK2, TRY_LOCK work with CWaitableCriticalSection
...
9c4dc597dd
Use LOCK macros for non-recursive locks (Russell Yanofsky)
1382913e61
Make LOCK, LOCK2, TRY_LOCK work with CWaitableCriticalSection (Russell Yanofsky)
ba1f095aad
MOVEONLY Move AnnotatedMixin declaration (Russell Yanofsky)
41b88e9337
Add unit test for DEBUG_LOCKORDER code (Russell Yanofsky)
Pull request description:
Make LOCK macros work with non-recursive mutexes, and use wherever possible for better deadlock detection.
Also add unit test for DEBUG_LOCKORDER code.
Tree-SHA512: 64ef209307f28ecd0813a283f15c6406138c6ffe7f6cbbd084161044db60e2c099a7d0d2edcd1c5e7770a115e9b931b486e86c9a777bdc96d2e8a9f4dc192942
2018-08-31 16:00:38 +02:00
Russell Yanofsky
41b88e9337
Add unit test for DEBUG_LOCKORDER code
2018-08-03 07:11:37 -05:00
DrahtBot
eb7daf4d60
Update copyright headers to 2018
2018-07-27 07:15:02 -04:00
MarcoFalke
fa9da85b7c
qa: Initialize lockstack to prevent null pointer deref
2018-05-22 06:31:26 -04:00
Chun Kuan Lee
84f41946b9
break circular dependency: random/sync -> util -> random/sync
2018-05-17 08:13:54 +00:00
John Newbery
5c21e6c6d3
[logging] Comment all continuing logs.
...
Most logs should terminated with a '\n'. Some logs
are built up over multiple calls to logPrintf(), so
do not need a newline terminater. Comment all of
these 'continued' logs as a linter hing.
2018-04-07 12:29:48 -04:00
Wladimir J. van der Laan
bd59c4395c
Merge #12859 : Bugfix: Include <memory> for std::unique_ptr
...
a5bca13
Bugfix: Include <memory> for std::unique_ptr (Luke Dashjr)
Pull request description:
Not sure why all these includes were missing, but it's breaking builds for some users:
https://bugs.gentoo.org/show_bug.cgi?id=652142
(Added to all files with a reference to `std::unique_ptr`)
Tree-SHA512: 8a2c67513ca07b9bb52c34e8a20b15e56f8af2530310d9ee9b0a69694dd05e02e7a3683f14101a2685d457672b56addec591a0bb83900a0eb8e2a43d43200509
2018-04-05 09:31:53 +02:00
Luke Dashjr
a5bca13095
Bugfix: Include <memory> for std::unique_ptr
2018-04-02 18:31:52 +00:00
practicalswift
1340eda3b7
Fix typos
2018-01-28 13:21:25 +01:00
Akira Takizawa
595a7bab23
Increment MIT Licence copyright header year on files modified in 2017
2018-01-03 02:26:56 +09:00
Cory Fields
f7f7e2cd34
threads: add a thread_local autoconf check
2017-11-27 15:01:47 -08:00
Thomas Snider
bba9bd0d9d
Switched sync.{cpp,h} to std threading primitives.
2017-11-18 11:35:14 -08:00
MeshCollider
1a445343f6
scripted-diff: Replace #include "" with #include <> (ryanofsky)
...
-BEGIN VERIFY SCRIPT-
for f in \
src/*.cpp \
src/*.h \
src/bench/*.cpp \
src/bench/*.h \
src/compat/*.cpp \
src/compat/*.h \
src/consensus/*.cpp \
src/consensus/*.h \
src/crypto/*.cpp \
src/crypto/*.h \
src/crypto/ctaes/*.h \
src/policy/*.cpp \
src/policy/*.h \
src/primitives/*.cpp \
src/primitives/*.h \
src/qt/*.cpp \
src/qt/*.h \
src/qt/test/*.cpp \
src/qt/test/*.h \
src/rpc/*.cpp \
src/rpc/*.h \
src/script/*.cpp \
src/script/*.h \
src/support/*.cpp \
src/support/*.h \
src/support/allocators/*.h \
src/test/*.cpp \
src/test/*.h \
src/wallet/*.cpp \
src/wallet/*.h \
src/wallet/test/*.cpp \
src/wallet/test/*.h \
src/zmq/*.cpp \
src/zmq/*.h
do
base=${f%/*}/ relbase=${base#src/} sed -i "s:#include \"\(.*\)\"\(.*\):if test -e \$base'\\1'; then echo \"#include <\"\$relbase\"\\1>\\2\"; else echo \"#include <\\1>\\2\"; fi:e" $f
done
-END VERIFY SCRIPT-
2017-11-16 08:23:01 +13:00
Matt Corallo
2b4b34503f
Add ability to assert a lock is not held in DEBUG_LOCKORDER
2017-10-13 19:29:54 -04:00
João Barbosa
92848e5058
Remove unused fTry from push_lock
2017-09-30 22:43:55 +01:00
practicalswift
36d326e8b0
Use nullptr instead of zero (0) as the null pointer constant
2017-08-16 10:24:18 +02:00
practicalswift
90d4d89230
scripted-diff: Use the C++11 keyword nullptr to denote the pointer literal instead of the macro NULL
...
-BEGIN VERIFY SCRIPT-
sed -i 's/\<NULL\>/nullptr/g' src/*.cpp src/*.h src/*/*.cpp src/*/*.h src/qt/*/*.cpp src/qt/*/*.h src/wallet/*/*.cpp src/wallet/*/*.h src/support/allocators/*.h
sed -i 's/Prefer nullptr, otherwise SAFECOOKIE./Prefer NULL, otherwise SAFECOOKIE./g' src/torcontrol.cpp
sed -i 's/tor: Using nullptr authentication/tor: Using NULL authentication/g' src/torcontrol.cpp
sed -i 's/METHODS=nullptr/METHODS=NULL/g' src/test/torcontrol_tests.cpp src/torcontrol.cpp
sed -i 's/nullptr certificates/NULL certificates/g' src/qt/paymentserver.cpp
sed -i 's/"nullptr"/"NULL"/g' src/torcontrol.cpp src/test/torcontrol_tests.cpp
-END VERIFY SCRIPT-
2017-08-07 07:36:37 +02:00
Jorge Timón
5995735c5b
scripted-diff: Remove #include <boost/foreach.hpp>
...
-BEGIN VERIFY SCRIPT-
sed -i ':a;N;$!ba;s/#include <boost\/foreach.hpp>\n//' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp
-END VERIFY SCRIPT-
2017-06-22 03:48:52 +02:00
Jorge Timón
1238f13cf6
scripted-diff: Remove PAIRTYPE
...
-BEGIN VERIFY SCRIPT-
sed -i 's/PAIRTYPE(\([^,]*\), \([^\)]*\))/std::pair<\1, \2>/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
sed -i ':a;N;$!ba;s/#define std::pair<t1, t2> std::pair<t1, t2>\n//' ./src/utilstrencodings.h ;
-END VERIFY SCRIPT-
2017-06-05 20:14:53 +02:00
Jorge Timón
7c00c26726
scripted-diff: Fully remove BOOST_FOREACH
...
-BEGIN VERIFY SCRIPT-
sed -i 's/BOOST_FOREACH *(\(.*\),/for (\1 :/' ./src/*.h ./src/*.cpp ./src/*/*.h ./src/*/*.cpp ./src/*/*/*.h ./src/*/*/*.cpp ;
-END VERIFY SCRIPT-
2017-06-05 20:10:50 +02:00
practicalswift
8dc957ae06
Remove unused code
2017-03-17 04:37:43 +01:00
Matt Corallo
618ee9249b
Further-enforce lockordering by enforcing directly after TRY_LOCKs
2017-02-07 14:15:28 -05:00
Matt Corallo
8465631845
Always enforce lock strict lock ordering (try or not)
2017-02-02 22:31:27 -05:00
isle2983
27765b6403
Increment MIT Licence copyright header year on files modified in 2016
...
Edited via:
$ contrib/devtools/copyright_header.py update .
2016-12-31 11:01:21 -07:00
Pieter Wuille
5eeb913d6c
Clean up lockorder data of destroyed mutexes
...
The lockorder potential deadlock detection works by remembering for each
lock A that is acquired while holding another B the pair (A,B), and
triggering a warning when (B,A) already exists in the table.
A and B in the above text are represented by pointers to the CCriticalSection
object that is acquired. This does mean however that we need to clean up the
table entries that refer to any critical section which is destroyed, as it
memory address can potentially be used for another unrelated lock in the future.
Implement this clean up by remembering not only the pairs in forward direction,
but also backward direction. This allows for fast iteration over all pairs that
use a deleted CCriticalSection in either the first or the second position.
2016-04-10 14:27:10 +02:00
MarcoFalke
fa24439ff3
Bump copyright headers to 2015
2015-12-13 18:08:39 +01:00
Cory Fields
9493803f4a
Revert "Revert "Assert on probable deadlocks if the second lock isnt try_lock""
...
This reverts commit a4fe57da62
.
The issue here should be fixed by the previous commit.
2015-08-07 16:18:16 -04:00
Wladimir J. van der Laan
a4fe57da62
Revert "Assert on probable deadlocks if the second lock isnt try_lock"
...
Disabling this for now - too many intermittent Travis issues.
This reverts commit 0fcc4e1e04
(pull #5515 ).
2015-08-06 14:15:54 +02:00
Matt Corallo
0fcc4e1e04
Assert on probable deadlocks if the second lock isnt try_lock
2015-07-22 16:49:54 -07:00
Matt Corallo
1ec900a29e
Remove broken+useless lock/unlock log prints
2015-04-24 02:28:47 -07:00
sandakersmann
f914f1a746
Added "Core" to copyright headers
...
Github-Pull: #5494
Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
2014-12-19 19:55:32 +01:00
Michael Ford
78253fcbad
Remove references to X11 licence
2014-12-16 15:56:50 +08:00
Pieter Wuille
20e01b1a03
Apply clang-format on some infrequently-updated files
2014-09-19 19:21:46 +02:00
Philip Kaufmann
611116d4e3
header include cleanup
...
- ensures alphabetical ordering for includes etc. in source file headers
2014-09-14 12:43:56 +02:00
Wladimir J. van der Laan
d2d6f708e4
Fix build with DEBUG_LOCKORDER
...
Fixes #4771
2014-08-28 01:52:22 +02:00
Gavin Andresen
ca4cf5cff6
Wallet locking fixes for -DDEBUG_LOCKORDER
...
Compiling with -DDEBUG_LOCKORDER and running the qa/rpc-test/ regression
tests uncovered a couple of wallet methods that should (but didn't)
acquire the cs_wallet mutext.
I also changed the AssertLockHeld() routine print to stderr and
abort, instead of printing to debug.log and then assert()'ing.
It is annoying to look in debug.log to find out which
AssertLockHeld is failing.
2014-02-18 12:11:46 -05:00
Wladimir J. van der Laan
7d9d134bf9
Remove redundant .c_str()s
...
After the tinyformat switch sprintf() family functions support passing
actual std::string objects.
Remove unnecessary c_str calls (236 of them) in logging and formatting.
2014-01-23 16:05:01 +01:00
Wladimir J. van der Laan
19a5676280
Use mutex pointer instead of name for AssertLockHeld
...
This makes it useable for non-global locks such as the wallet and
keystore locks.
2013-12-19 09:46:11 +01:00
Gavin Andresen
c649637b6c
mutex debugging routines: LocksHeld() and AssertLockHeld()
2013-11-29 17:46:19 +10:00
Brandon Dahler
51ed9ec971
Cleanup code using forward declarations.
...
Use misc methods of avoiding unnecesary header includes.
Replace int typedefs with int##_t from stdint.h.
Replace PRI64[xdu] with PRI[xdu]64 from inttypes.h.
Normalize QT_VERSION ifs where possible.
Resolve some indirect dependencies as direct ones.
Remove extern declarations from .cpp files.
2013-11-10 09:36:28 -06:00
Gavin Andresen
3b9ecfed82
Make -DDEBUGLOCKORDER + -debug less noisy
...
Print out every mutex lock/unlock if compiled -DDEBUGLOCKORDER
only if -debug=lock is set.
2013-10-20 15:41:15 +10:00
Gavin Andresen
881a85a22d
Replace printf with LogPrintf / LogPrint
2013-09-18 20:39:25 +10:00
Jeff Garzik
ea0796bde3
Trim trailing whitespace for src/*.{h,cpp}
2012-09-18 15:07:58 -04:00
fanquake
e749405297
Fix a few typos
2012-06-29 17:26:45 +08:00
Matt Corallo
4d009243cb
Fix DEBUG_LOCKCONTENTION
2012-06-05 16:13:16 +02:00
Pieter Wuille
46784d0826
Merge pull request #1354 from fanquake/master
...
Update Header Licenses
2012-05-20 12:27:50 -07:00
Pieter Wuille
660ff174f2
Use boost::thread locking instead of interprocess
2012-05-18 16:56:12 +02:00