MCPcopy
hub / github.com/google/gvisor / testInconsistentBranching

Function testInconsistentBranching

tools/checklocks/test/branches.go:42–56  ·  view source on GitHub ↗
(tc *oneGuardStruct)

Source from the content-addressed store, hash-verified

40}
41
42func testInconsistentBranching(tc *oneGuardStruct) { // +checklocksfail=incompatible return states|incompatible return states
43 // We traverse the control flow graph in all consistent ways. We cannot
44 // determine however, that the first if block and second if block will
45 // evaluate to the same condition. Therefore, there are two consistent
46 // paths through this code, and two inconsistent paths. Either way, the
47 // guardedField should be also marked as an invalid access.
48 x := rand.Intn(10)
49 if x%2 == 1 {
50 tc.mu.Lock()
51 }
52 tc.guardedField = 1 // +checklocksfail
53 if x%2 == 1 {
54 tc.mu.Unlock() // +checklocksforce
55 }
56}
57
58func testUnboundedLocks(tc []*oneGuardStruct) {
59 for _, l := range tc {

Callers

nothing calls this directly

Calls 2

LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…