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

Immediately call adapter.Connect(addr) after device.Disconnect() will cause DiscoverServices() panic #278

Open
linteck opened this issue Jun 13, 2024 · 0 comments

Comments

@linteck
Copy link

linteck commented Jun 13, 2024

On Macbook Pro:
tinygo.org/x/bluetooth v0.9.0

Immediately call adapter.Connect(addr) after device.Disconnect() will cause device.DiscoverServices() crash

   ```

device, err := b.adapter.Connect(b.Address, bluetooth.ConnectionParams{})
if err != nil {
return nil, err
}

srvcs, err := device.DiscoverServices([]bluetooth.UUID{serviceUUID})
if err != nil {
	return nil, err
}

device.Disconnect()

// Do connection again
device, err := b.adapter.Connect(b.Address, bluetooth.ConnectionParams{})
if err != nil {
return nil, err
}

srvcs, err := device.DiscoverServices([]bluetooth.UUID{serviceUUID})
if err != nil {
	return nil, err
}

Stack trace:

panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x109973935]

goroutine 7 [running]:
testing.tRunner.func1.2({0x1099cdd80, 0x109ac1960})
	/Users/my/sdk/go1.22.4/src/testing/testing.go:1631 +0x24a
testing.tRunner.func1()
	/Users/my/sdk/go1.22.4/src/testing/testing.go:1634 +0x377
panic({0x1099cdd80?, 0x109ac1960?})
	/Users/my/sdk/go1.22.4/src/runtime/panic.go:770 +0x132
tinygo.org/x/bluetooth.Device.DiscoverServices({{{0x0, 0x0, 0x0, 0x0}}, 0x0}, {0xc000069d00, 0x1, 0x109ac6a40?})
	
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