andreykaipov / goobs

Go client library for OBS Studio
Apache License 2.0
137 stars 22 forks source link

panic: runtime error: invalid memory address or nil pointer dereference #58

Closed Vany closed 11 months ago

Vany commented 1 year ago

[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x100c7234c]

goroutine 37 [running]: github.com/andreykaipov/goobs.(Client).Disconnect(0x0) /Users/vany/go/pkg/mod/github.com/andreykaipov/goobs@v0.12.1/client.go:89 +0x1c github.com/vany/controlrake/src/obs.(Obs).Init.func1() /Users/vany/a/controlrake/src/obs/obs.go:61 +0x12c created by github.com/vany/controlrake/src/obs.(*Obs).Init in goroutine 1 /Users/vany/a/controlrake/src/obs/obs.go:45 +0xe0

it is after obs was shuted down i called disconnect()
afriza commented 1 year ago

@Vany in my opinion, it seems to be some logic issue in your application. o.Client is nil when you call o.Client.Disconnect().

https://github.com/Vany/controlrake/blob/dc1d7b9a9ea6ba976555b3ed85ec50e0fb2125b8/src/obs/obs.go#L61

andreykaipov commented 1 year ago

Hey @Vany, sorry for the late reply but unfortunately I can't reproduce this by disconnecting after OBS is already shut down.

The stack trace is interesting though. It's indicating this is the problem line. So either c.Client.Log or c.Client is nil, but this should be impossible if called after goobs.New() because that's all initialized here.

Like @afriza mentioned, I think you've got something strange happening in your initialization code there. Could you provide a minimal reproducible example?

andreykaipov commented 11 months ago

I'm gonna close this out. I saw in the latest version of your code you have a nil check. I think that's a good way to go about it. I released a new major version v1.0.0 that includes some improvements to the disconnection logic as well as hiding any internal fields to make troubleshooting things like this easier in the future.