Ambre-io / sparkplugui

🕶️ SparkpluGUI displays decoded Sparkplug messages from MQTT IoT
GNU General Public License v3.0
9 stars 2 forks source link

linux build crashes when connecting to test.mosquitto.org #1

Open gaillarddamien opened 10 months ago

gaillarddamien commented 10 months ago

./SparkpluGUI-Linux v1.0.0

MQTT host: test.mosquitto.org port: 1883 subscribe to: spBv1.0/#

click 'connect', and the app crashes with the following error message:

Overriding existing handler for signal 10. Set JSC_SIGNAL_FOR_GC if you want WebKit to use a different signal
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x7743ee]

goroutine 11 [running]:
sparkplugui/backend/sparkplug.(*Payload).DecodePayload(0xc00008ff10, {0xc0001fe000, 0xda, 0xda})
        /home/guillaumeklimek/Projects/sparkplugui/backend/sparkplug/weekaung.go:122 +0x20e
sparkplugui/backend/core.(*App).decode(0x0?, {0xc0001fe000, 0xda, 0x0?})
        /home/guillaumeklimek/Projects/sparkplugui/backend/core/app.go:49 +0x49
sparkplugui/backend/core.(*App).CmdConnect.func1.1()
        /home/guillaumeklimek/Projects/sparkplugui/backend/core/commands.go:73 +0x46
created by sparkplugui/backend/core.(*App).CmdConnect.func1 in goroutine 47
        /home/guillaumeklimek/Projects/sparkplugui/backend/core/commands.go:72 +0x90
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x7743ee]

goroutine 8 [running]:
sparkplugui/backend/sparkplug.(*Payload).DecodePayload(0xc00008df10, {0xc000132190, 0x4a, 0x4a})
        /home/guillaumeklimek/Projects/sparkplugui/backend/sparkplug/weekaung.go:122 +0x20e
sparkplugui/backend/core.(*App).decode(0x0?, {0xc000132190, 0x4a, 0x0?})
        /home/guillaumeklimek/Projects/sparkplugui/backend/core/app.go:49 +0x49
sparkplugui/backend/core.(*App).CmdConnect.func1.1()
        /home/guillaumeklimek/Projects/sparkplugui/backend/core/commands.go:73 +0x46
created by sparkplugui/backend/core.(*App).CmdConnect.func1 in goroutine 47
        /home/guillaumeklimek/Projects/sparkplugui/backend/core/commands.go:72 +0x90
guiklimek commented 9 months ago

Oopsie doopsie 😅

Context

There is no tahu support for a Golang implementation of the sparkplug-payload nor the sparkplug-client.

I have found this as a code base: https://github.com/weekaung/sparkplugb-client.

Core

DecodePayload is directly involved in this error and the code use it like that: https://github.com/Ambre-io/sparkplugui/blob/main/backend/sparkplug/weekaung.go#L104.

I copied the code base and add method from the fresh compiled proto file: https://github.com/Ambre-io/sparkplugui/blob/main/backend/sparkplug/sproto/sparkplug_b.pb.go.

Understanding

It cannot or doesn't know how to decode an incoming message.

I don't yet have the type(s) of messages that are causing the problem here, because some work well, fortunately.

I'm still not sure to understand well what is happening here..

marchino2000 commented 3 months ago

Windows version crashes as well.

guiklimek commented 3 months ago

Hello @marchino2000, thank you for reporting this and sorry for the bad user experience with SparkpluGUI. Do you have more information to give like the context of usage?

I think there are two main problems:

For now, SparkpluGUI can't handle top-level topics that involve a large flow of messages.

Unfortunately, I currently can't do more for this. The cool thing is that with wes-johnson, the main maintainer of the tahu library, we discussed adding it to the Tahu Project. I will find a moment to make it true, SparkpluGUI gonna have better chance like that.

Also, if you want to contribute, feel free to create a PR!

Peace 🫰

marchino2000 commented 3 months ago

Hi @guiklimek , thank you for your reply. I find this gui a valuable utility to monitor sparkplug messages, so keep up with the good work! In my case it seems that crash is related to authentication fields: if you leave user and password empty, then you'll get the problem.