libusb icon indicating copy to clipboard operation
libusb copied to clipboard

datarace in hotplug callback map

Open bokunodev opened this issue 2 years ago • 0 comments

access to hotplugCallbackStorage is not protected by mutex.

==================
WARNING: DATA RACE
Read at 0x00c00009a330 by goroutine 7:
  runtime.mapaccess2_fast32()
      runtime/map_fast32.go:53 +0x0
  github.com/gotmc/libusb/v2.libusbHotplugCallback()
      github.com/gotmc/libusb/[email protected]/hotplug.go:203 +0xf0
  _cgoexp_0b0a3dd1d46c_libusbHotplugCallback()
      _cgo_gotypes.go:998 +0x99
  runtime.cgocallbackg1()
      runtime/cgocall.go:315 +0x2c2
  github.com/gotmc/libusb/v2.(*HotplugCallbackStorage).handleEvents.func1()
      github.com/gotmc/libusb/[email protected]/hotplug.go:176 +0x5b
  github.com/gotmc/libusb/v2.(*HotplugCallbackStorage).handleEvents()
      github.com/gotmc/libusb/[email protected]/hotplug.go:176 +0x5c
  github.com/gotmc/libusb/v2.(*Context).newHotPlugHandler.func1()
      github.com/gotmc/libusb/[email protected]/hotplug.go:65 +0x47

Previous write at 0x00c00009a330 by main goroutine:
  runtime.mapassign_fast32()
      runtime/map_fast32.go:93 +0x0
  github.com/gotmc/libusb/v2.(*Context).HotplugRegisterCallbackEvent()
      github.com/gotmc/libusb/[email protected]/hotplug.go:115 +0x147
  main.main()
      github.com/bokunodev/hid/main.go:36 +0xed

Goroutine 7 (running) created at:
  github.com/gotmc/libusb/v2.(*Context).newHotPlugHandler()
      github.com/gotmc/libusb/[email protected]/hotplug.go:65 +0x14b
  github.com/gotmc/libusb/v2.(*Context).HotplugRegisterCallbackEvent()
      github.com/gotmc/libusb/[email protected]/hotplug.go:75 +0x6b
  main.main()
      github.com/bokunodev/hid/main.go:32 +0xca
==================

bokunodev avatar Apr 19 '23 19:04 bokunodev