itctl panics on nil pointer #14

Closed
opened 2022-03-19 12:02:33 +00:00 by tuxick · 3 comments

After pulling (v0.0.4-54-g23e9195) itctl throws:

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

goroutine 1 [running]:
go.arsenm.dev/itd/api.(*Client).Close(...)
/home/tony/github/itd/api/client.go:57
main.main.func2(0xc000076500, 0x731354, 0xc000063710)
/home/tony/github/itd/cmd/itctl/main.go:187 +0x29
github.com/urfave/cli/v2.(*App).RunContext.func1(0xc00010eea0, 0xc000076500, 0xc00016bb78)
/home/tony/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:289 +0x3b
github.com/urfave/cli/v2.(*App).RunContext(0xc00010eea0, 0x78b430, 0xc000016110, 0xc000012040, 0x2, 0x2, 0x787820, 0xc000100320)
/home/tony/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:304 +0x948
github.com/urfave/cli/v2.(*App).Run(...)
/home/tony/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:224
main.main()
/home/tony/github/itd/cmd/itctl/main.go:191 +0x147d

I also noticed go get -u complaining

blefs.transferChar.Properties.MTU undefined (type *gatt.GattCharacteristic1Properties has no field or method MTU)

go version go1.16.14 linux/amd64
bluez 5.55-3.1

After pulling (v0.0.4-54-g23e9195) itctl throws: panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x6a6769] goroutine 1 [running]: go.arsenm.dev/itd/api.(*Client).Close(...) /home/tony/github/itd/api/client.go:57 main.main.func2(0xc000076500, 0x731354, 0xc000063710) /home/tony/github/itd/cmd/itctl/main.go:187 +0x29 github.com/urfave/cli/v2.(*App).RunContext.func1(0xc00010eea0, 0xc000076500, 0xc00016bb78) /home/tony/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:289 +0x3b github.com/urfave/cli/v2.(*App).RunContext(0xc00010eea0, 0x78b430, 0xc000016110, 0xc000012040, 0x2, 0x2, 0x787820, 0xc000100320) /home/tony/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:304 +0x948 github.com/urfave/cli/v2.(*App).Run(...) /home/tony/go/pkg/mod/github.com/urfave/cli/v2@v2.3.0/app.go:224 main.main() /home/tony/github/itd/cmd/itctl/main.go:191 +0x147d I also noticed go get -u complaining blefs.transferChar.Properties.MTU undefined (type *gatt.GattCharacteristic1Properties has no field or method MTU) go version go1.16.14 linux/amd64 bluez 5.55-3.1
Author

Ok,it's bad error/exception handling which might need some fixing.
Important: https://learn.adafruit.com/introduction-to-bluetooth-low-energy/gatt "keep in mind with GATT and connections is that connections are exclusive"

Playing and researching lead to short HOWTO:

  • make sure your device is not connected to for example gadgetbridge
    (or you get errors like "src/device.c:load_gatt_db() No cache for XXX"
  • bluetoothctl pair your:device:id
    (watch should show a code to enter on bluetoothctl prompt)
  • systemctl --user restart itd
  • itctl notify your:device:id "Hello world"
    (undocumented feature :)
Ok,it's bad error/exception handling which might need some fixing. Important: https://learn.adafruit.com/introduction-to-bluetooth-low-energy/gatt "keep in mind with GATT and connections is that connections are exclusive" Playing and researching lead to short HOWTO: * make sure your device is not connected to for example gadgetbridge (or you get errors like "src/device.c:load_gatt_db() No cache for XXX" * bluetoothctl pair <your:device:id> (watch should show a code to enter on bluetoothctl prompt) * systemctl --user restart itd * itctl notify <your:device:id> "Hello world" (undocumented feature :)
Owner

You cannot supply the device id (MAC Address) to itctl. It will notify whatever is connected to itd, and cannot do it to any other device. The first argument to itctl notify acts as the title of the notification, the second as the body.

The reason for the error you're seeing appears to be that your BlueZ version is too old. I believe at least 5.62 is required for the MTU field.

The itctl error is because it's trying to close a client that was never opened because itd was never running. Without that MTU field, itd cannot compile. I do need to find a solution to this, but unfortunately, the library I am using for bluetooth (the only one available), stops working when a feature is added or removed. That's just because the entire library is auto generated.

You cannot supply the device id (MAC Address) to itctl. It will notify whatever is connected to itd, and cannot do it to any other device. The first argument to `itctl notify` acts as the title of the notification, the second as the body. The reason for the error you're seeing appears to be that your BlueZ version is too old. I believe at least 5.62 is required for the MTU field. The itctl error is because it's trying to close a client that was never opened because itd was never running. Without that MTU field, itd cannot compile. I do need to find a solution to this, but unfortunately, the library I am using for bluetooth (the only one available), stops working when a feature is added or removed. That's just because the entire library is auto generated.
Owner

I will fix the itctl error handling, but there isn't much I can currently do about the BlueZ version issue.

I will fix the itctl error handling, but there isn't much I can currently do about the BlueZ version issue.
Elara6331 added the
Bug
In Progress
labels 2022-03-19 18:58:11 +00:00
Elara6331 added this to the 0.0.5 milestone 2022-04-02 20:01:53 +00:00
Elara6331 removed the
In Progress
label 2022-04-02 22:20:48 +00:00
Sign in to join this conversation.
No description provided.