From acb4c62885629d6d3ee977b93c27282abed0b33f Mon Sep 17 00:00:00 2001 From: Rahat Mahmood Date: Tue, 23 Mar 2021 11:54:55 -0700 Subject: Skip checklocks analysis for stateify generated code. Stateify methods are always called without holding the appropriate locks. The system is paused and we know there will be no mutations when we call Save/Load, so this is perfectly safe. However, checklocks can't know about this, and it will always complain. Mark stateify generated methods that touch struct fields as "checklocksignore" to avoid this. PiperOrigin-RevId: 364610241 --- tools/go_stateify/main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/go_stateify/main.go b/tools/go_stateify/main.go index e1de12e25..93022f504 100644 --- a/tools/go_stateify/main.go +++ b/tools/go_stateify/main.go @@ -403,6 +403,7 @@ func main() { // on this specific behavior, but the ability to specify slots // allows a manual implementation to be order-dependent. if generateSaverLoader { + fmt.Fprintf(outputFile, "// +checklocksignore\n") fmt.Fprintf(outputFile, "func (%s *%s) StateSave(stateSinkObject %sSink) {\n", recv, ts.Name.Name, statePrefix) fmt.Fprintf(outputFile, " %s.beforeSave()\n", recv) scanFields(x, "", scanFunctions{zerovalue: emitZeroCheck}) @@ -425,6 +426,7 @@ func main() { // // N.B. See the comment above for the save method. if generateSaverLoader { + fmt.Fprintf(outputFile, "// +checklocksignore\n") fmt.Fprintf(outputFile, "func (%s *%s) StateLoad(stateSourceObject %sSource) {\n", recv, ts.Name.Name, statePrefix) scanFields(x, "", scanFunctions{normal: emitLoad, wait: emitLoadWait}) scanFields(x, "", scanFunctions{value: emitLoadValue}) -- cgit v1.2.3