google / gvisor

Application Kernel for Containers

Home Page:https://gvisor.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Specify locking requirements with checklocks

ghananigans opened this issue · comments

checklocks simply checks for Lock/Unlock but doesn't distinguish between read/write locking requirements.

  1. we may need write locks but checklocks passes with read locks (the following test is testing for wrong behaviour)

    func testRWValidWrite(tc *rwGuardStruct) {
    tc.rwMu.RLock()
    tc.guardedField = 2
    tc.rwMu.RUnlock()
    }

  2. A method may only need read OR write locks but checklocks does not yet support annotating it with that minimum requirement.

I think there was problem with the generated SSA where it was hard to distinguish this use-case. I will have to revisit this to refresh my memory why we did not support this.

I don't think this is difficult anymore. I can knock this out soon.

Also the test right above it has the wrong name - it writes rather than reads.

func testRWValidRead(tc *rwGuardStruct) {
tc.rwMu.Lock()
tc.guardedField = 1
tc.rwMu.Unlock()
}