diff options
author | Rahat Mahmood <rahat@google.com> | 2021-03-23 11:54:55 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-03-23 11:56:59 -0700 |
commit | acb4c62885629d6d3ee977b93c27282abed0b33f (patch) | |
tree | 3fa1b21e3175a306508f034bb457f00b1ade1d41 | |
parent | beb11cec7669d029172751e5b4dfe21c0672a25a (diff) |
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
-rw-r--r-- | tools/go_stateify/main.go | 2 |
1 files changed, 2 insertions, 0 deletions
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}) |