Skip to content

Commit dbba388

Browse files
authored
Merge pull request #312 from github/jsinglet/CON56-CPP-QCC
CON56-CPP QCC Fixes
2 parents beda676 + 6e8ef10 commit dbba388

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

cpp/cert/src/rules/CON56-CPP/DoNotSpeculativelyLockALockedNonRecursiveMutex.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import codingstandards.cpp.Concurrency
1919
from LockProtectedControlFlowNode n
2020
where
2121
not isExcluded(n, ConcurrencyPackage::doNotSpeculativelyLockALockedNonRecursiveMutexQuery()) and
22-
// problematic nodes are ones where a lock is active and there is an attempt to
23-
// call a speculative locking function
22+
// problematic nodes are ones where a lock is active and there is an attempt
23+
// to call a speculative locking function
2424
n.(MutexFunctionCall).isSpeculativeLock() and
2525
not n.(MutexFunctionCall).isRecursive() and
2626
n.getAProtectingLock() = n.(MutexFunctionCall).getLock()

cpp/cert/src/rules/CON56-CPP/LockedALockedNonRecursiveMutexAudit.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import codingstandards.cpp.Concurrency
1919
from LockProtectedControlFlowNode n
2020
where
2121
not isExcluded(n, ConcurrencyPackage::lockedALockedNonRecursiveMutexAuditQuery()) and
22-
// problematic nodes are ones where a lock is active and there is an attempt to
23-
// call a speculative locking function
22+
// problematic nodes are ones where a lock is active and there is an attempt
23+
// to call a speculative locking function
2424
n.(MutexFunctionCall).isSpeculativeLock() and
2525
not n.(MutexFunctionCall).isRecursive()
2626
select n, "(Audit) Attempt to speculatively lock a non-recursive mutex while it is $@.",

cpp/common/src/codingstandards/cpp/Concurrency.qll

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,9 +399,14 @@ class LockProtectedControlFlowNode extends ThreadedCFN {
399399
not exists(ControlFlowNode unlock |
400400
// it's an unlock
401401
unlock = getAThreadContextAwarePredecessor(lock, this) and
402-
unlock.(MutexFunctionCall).isUnlock()
402+
unlock.(MutexFunctionCall).isUnlock() and
403403
// note that we don't check that it's the same lock -- this is left
404404
// to the caller to enforce this condition.
405+
// Because of the way that `getAThreadContextAwarePredecessor` works, it is possible
406+
// for operations PAST it to be technically part of the predecessors.
407+
// Thus, we need to make sure that this node is a
408+
// successor of the unlock in the CFG
409+
getAThreadContextAwareSuccessor(unlock) = this
405410
) and
406411
(lock instanceof MutexFunctionCall implies not this.(MutexFunctionCall).isUnlock())
407412
)

cpp/common/test/rules/ownedpointervaluestoredinunrelatedsmartpointer/OwnedPointerValueStoredInUnrelatedSmartPointer.expected.qcc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ edges
5151
| test.cpp:17:27:17:28 | v1 | file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:3757:34:3757:36 | __p |
5252
| test.cpp:17:27:17:28 | v1 | test.cpp:17:27:17:28 | ref arg v1 |
5353
| test.cpp:19:6:19:7 | v1 | test.cpp:3:14:3:15 | v1 |
54-
nodes
54+
nodes
5555
| file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:2469:31:2469:33 | __p | semmle.label | __p |
5656
| file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:2469:31:2469:33 | __p | semmle.label | __p |
5757
| file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:3611:30:3611:32 | __p | semmle.label | __p |
@@ -92,7 +92,7 @@ edges
9292
| test.cpp:17:27:17:28 | v1 | semmle.label | v1 |
9393
| test.cpp:17:27:17:28 | v1 | semmle.label | v1 |
9494
| test.cpp:19:6:19:7 | v1 | semmle.label | v1 |
95-
subpaths
95+
subpaths
9696
| file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:4065:28:4065:30 | __p | file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:2469:31:2469:33 | __p | file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:2469:31:2469:33 | __p | file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:4065:28:4065:30 | ref arg __p |
9797
| file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:4068:30:4068:32 | __p | file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:3611:30:3611:32 | __p | file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:3611:30:3611:32 | __p | file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:4068:30:4068:32 | ref arg __p |
9898
| test.cpp:5:27:5:28 | v1 | file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:3757:34:3757:36 | __p | file:///opt/qcc/qnx-sdp/target/qnx7/usr/include/c++/v1/memory:4063:7:4063:17 | constructor init of field __ptr_ [post-this] [__ptr_] | test.cpp:5:27:5:29 | call to shared_ptr [__ptr_] |

0 commit comments

Comments
 (0)