Have you seen any static analysis checker for sync.Mutex.Unlock() call?

273 views
Skip to first unread message

たふみ

unread,
Sep 21, 2021, 3:42:21 AM9/21/21
to golang-nuts
Hi,

I'm seeking the static analysis checker (go vet tool) for missed call sync.Mutex.Unlock().

For example: source code is like

type T struct {
  mu sync.Mutex
}

func (t *T) A(a bool) {
  t.mu.Lock()

  if (a) {
    // here missing t.mu.Unlock()
    return
  }
  t.mu.Unlock()
}

and by running go vet -vettool SOME_AWESOME_CHECKER, I want to find the absent of Unlock().

Currently, I'm developing this kind of tool (progress is about 60%), but if it exists, I don't want to reinvent the wheel.

So if you have ever seen any other related project, please let me know.

Thanks, 
Tafumi

Aram Hăvărneanu

unread,
Sep 21, 2021, 6:58:17 AM9/21/21
to たふみ, golang-nuts
Congratulations on solving the halting problem!

PS: use defer otherwise you aren't panic-safe.

--
Aram Hăvărneanu

Subham

unread,
Jan 22, 2022, 6:02:20 PM1/22/22
to golang-nuts
Hey Tafumi,

Were you able to complete this? I was recently thinking about this. I'd love to see if you have it somewhat working (or even learn about the ideas you thought of).

Thanks,

Subham

たふみ

unread,
Jan 23, 2022, 4:59:19 AM1/23/22
to golang-nuts
Hi Subham,

Yes, it was partially completed. 
But sorry, I'm currently working on a paper based on this tool, so cannot make it public.
Maybe within 2 weeks, it will be released on GitHub.

Tafumi

2022年1月23日日曜日 8:02:20 UTC+9 Subham:
Reply all
Reply to author
Forward
0 new messages