Skip to content

tools/checklocks: Generics support #11671

Open
@kakkoyun

Description

@kakkoyun

Description

First of all, thanks for the awesome project. I even find the tooling amazing.

I'm trying to use https://github.com/google/gvisor/blob/master/tools/checklocks/README.md on a project where the code uses generics and I assume that it fails to recognize the annotations.

The code:

// GenericResource demonstrates a resource with some fields guarded by a mutex.
// This version uses generics to see if checklocks works with generic types.
type GenericResource[T any] struct {
	mu sync.Mutex
	// +checklocks:mu
	value T
}

The error I got:

pkg/resource/generic_resource.go:15:2: may require checklocks annotation for mu, used with lock held 100% of the time

I assume the tool misses generic support.

I would be happy to contribute back if you are willing to accept contributions.

I would appreciate any pointers.

Is this feature related to a specific bug?

No response

Do you have a specific solution in mind?

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions