Skip to content

sync: document RWMutex.RLock shouldn't be used recursively #7576

@dvyukov

Description

@dvyukov
Detected by experimental deadlock detector in cl/77450043.

==================
WARNING: DEADLOCK
Goroutine 999 lock mutex 35 while holding mutex 35:
  sync.(*RWMutex).RLock()
      src/pkg/sync/rwmutex.go:42 +0xa2
  sync.(*rlocker).Lock()
      src/pkg/sync/rwmutex.go:133 +0x34
  sync_test.func·027()
      src/pkg/sync/rwmutex_test.go:132 +0xb6

Mutex 35 was previously locked here:
  sync.(*RWMutex).RLock()
      src/pkg/sync/rwmutex.go:42 +0xa2
  sync.(*rlocker).Lock()
      src/pkg/sync/rwmutex.go:133 +0x34
  sync_test.func·027()
      src/pkg/sync/rwmutex_test.go:133 +0xda
==================

==================
WARNING: DEADLOCK
Goroutine 999 lock mutex 16 while holding mutex 16:
  sync.(*RWMutex).RLock()
      src/pkg/sync/rwmutex.go:42 +0xa2
  sync_test.func·028()
      src/pkg/sync/rwmutex_test.go:166 +0x88
  testing.func·002()
      src/pkg/testing/benchmark.go:416 +0x17d

Mutex 16 was previously locked here:
  sync.(*RWMutex).RLock()
      src/pkg/sync/rwmutex.go:42 +0xa2
  sync_test.func·028()
      src/pkg/sync/rwmutex_test.go:167 +0x96
  testing.func·002()
      src/pkg/testing/benchmark.go:416 +0x17d
==================

Tests lock RWMutex recursively. RWMutex is not recursive.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions