Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error: concurrent map writes / ble.ReadCharacteristic() gets stuck #46

Open
matti777 opened this issue Jul 25, 2017 · 1 comment

Comments

@matti777
Copy link

matti777 commented Jul 25, 2017

I'm getting the following error when calling ble.Connect():

2017/07/25 16:13:59 Unhandled event: xpc.Dict{"kCBMsgId":54, "kCBMsgArgs":xpc.Dict{"kCBMsgArgServiceStartHandle":10, "kCBMsgArgDeviceUUID":xpc.UUID{0x26, 0x80, 0x8d, 0x10, 0xb, 0xa8, 0x46, 0xfb, 0xbb, 0x58, 0xa2, 0x7e, 0xe1, 0x90, 0xc, 0x7c}, "kCBMsgArgServiceEndHandle":65535}}
fatal error: concurrent map writes

goroutine 17 [running, locked to thread]:
runtime.throw(0x44aebec, 0x15)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/panic.go:596 +0x95 fp=0xc42004da28 sp=0xc42004da08
runtime.mapassign(0x4422340, 0xc42015e0f0, 0xc42004db88, 0xc4201fb600)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/hashmap.go:499 +0x667 fp=0xc42004dac8 sp=0xc42004da28
github.com/currantlabs/ble/darwin.(*Device).conn(0xc42008c500, 0xc4201f0c00, 0x44a7755)
	/Users/matti/go/src/github.com/currantlabs/ble/darwin/device.go:500 +0x414 fp=0xc42004dbc0 sp=0xc42004dac8
github.com/currantlabs/ble/darwin.(*Device).HandleXpcEvent(0xc42008c500, 0xc4201f0bd0, 0x0, 0x0)
	/Users/matti/go/src/github.com/currantlabs/ble/darwin/device.go:448 +0x190f fp=0xc42004de20 sp=0xc42004dbc0
github.com/raff/goble/xpc.handleXpcEvent(0x4a00ac0, 0xc420051de8)
	/Users/matti/go/src/github.com/raff/goble/xpc/xpc.go:229 +0x242 fp=0xc42004de90 sp=0xc42004de20
github.com/raff/goble/xpc._cgoexpwrap_f507673fb4e8_handleXpcEvent(0x4a00ac0, 0xc420051de8)
	github.com/raff/goble/xpc/_obj/_cgo_gotypes.go:460 +0x35 fp=0xc42004deb0 sp=0xc42004de90
runtime.call32(0x0, 0x7000050d0248, 0x7000050d02e8, 0x10)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/asm_amd64.s:514 +0x48 fp=0xc42004dee0 sp=0xc42004deb0
runtime.cgocallbackg1(0x0)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/cgocall.go:301 +0x19d fp=0xc42004df58 sp=0xc42004dee0
runtime.cgocallbackg(0x0)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/cgocall.go:184 +0x84 fp=0xc42004dfc0 sp=0xc42004df58
runtime.cgocallback_gofunc(0x0, 0x0, 0x0, 0x0)
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/asm_amd64.s:767 +0x74 fp=0xc42004dfe0 sp=0xc42004dfc0
runtime.goexit()
	/usr/local/Cellar/go/1.8.1/libexec/src/runtime/asm_amd64.s:2197 +0x1 fp=0xc42004dfe8 sp=0xc42004dfe0

This could be just me misusing the library (or Golang, for I am quite a beginner with the language still), but with next to no documentation for the lib I am not sure..

So I am doing the Connect() call from within the AdvHandler func of my Scan() call. I have tried using the same exact context.Context as well as a fresh new one (allocated new one per each Connect() call) but neither way seems to work. Sometimes it crashes like this, sometimes Connect() succeeds but then the whole program gets stuck on ble.ReadCharacteristic() call I am making, following the Connect() (and DiscoverProfile() etc).

I am running this on MacBook Pro PC, OSX Sierra 10.12.6, go version go1.8.1 darwin/amd64

The device I am trying to Connect() to is an iPhone6 with the latest iOS (10.3.2)

  • Matti
@matti777 matti777 changed the title fatal error: concurrent map writes / ble.DiscoverProfile() gets stuck fatal error: concurrent map writes / ble.ReadCharacteristic() gets stuck Jul 25, 2017
@matti777
Copy link
Author

To me it seems like Scan() and Connect() are interfering with each other, even if I do the Connect() in a new goroutine. Should I abort the Scan() (using a context.WithTimeout() ?) before making the Connects() to the devices found?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant