Skip to content

Commit de4eef5

Browse files
theunikevkevinpal
authored andcommitted
threading: use correct mutex name in reverse_lock fatal error messages
Now that REVERSE_LOCK requires the name of the actual mutex, it can be used for better error messages.
1 parent a201a99 commit de4eef5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/sync.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class SCOPED_LOCKABLE UniqueLock : public MutexType::unique_lock
248248
// it is not possible to use the lock's copy of the mutex for that purpose.
249249
// Instead, the original mutex needs to be passed back to the reverse_lock for
250250
// the sake of thread-safety analysis, but it is not actually used otherwise.
251-
#define REVERSE_LOCK(g, cs) typename std::decay<decltype(g)>::type::reverse_lock UNIQUE_NAME(revlock)(g, cs, #g, __FILE__, __LINE__)
251+
#define REVERSE_LOCK(g, cs) typename std::decay<decltype(g)>::type::reverse_lock UNIQUE_NAME(revlock)(g, cs, #cs, __FILE__, __LINE__)
252252

253253
// When locking a Mutex, require negative capability to ensure the lock
254254
// is not already held

src/test/reverselock_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ BOOST_AUTO_TEST_CASE(reverselock_errors)
5454
g_debug_lockorder_abort = false;
5555

5656
// Make sure trying to reverse lock a previous lock fails
57-
BOOST_CHECK_EXCEPTION(REVERSE_LOCK(lock2, mutex2), std::logic_error, HasReason("lock2 was not most recent critical section locked"));
57+
BOOST_CHECK_EXCEPTION(REVERSE_LOCK(lock2, mutex2), std::logic_error, HasReason("mutex2 was not most recent critical section locked"));
5858
BOOST_CHECK(lock2.owns_lock());
5959

6060
g_debug_lockorder_abort = prev;

0 commit comments

Comments
 (0)