ncruces / zenity

Zenity dialogs for Golang, Windows, macOS
https://pkg.go.dev/github.com/ncruces/zenity
MIT License
736 stars 37 forks source link

Progress dialog panics when cancelled on Linux #39

Closed billy4479 closed 1 year ago

billy4479 commented 1 year ago

If a progress dialog is cancelled or closed by the user (by clicking on the "Cancel" button or by closing the window) it causes the whole program to panic.

The panic log looks like:

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

goroutine 20 [running]:
bytes.(*Buffer).Bytes(...)
        /usr/lib/go/src/bytes/buffer.go:54
github.com/ncruces/zenity/internal/zenutil.(*progressDialog).wait(0xc0000d6000, 0x0, 0x0)
        /home/billy/go/pkg/mod/github.com/ncruces/zenity@v0.9.3/internal/zenutil/progress_unix.go:81 +0x133
created by github.com/ncruces/zenity/internal/zenutil.RunProgress
        /home/billy/go/pkg/mod/github.com/ncruces/zenity@v0.9.3/internal/zenutil/run_unix.go:80 +0x60c
exit status 2

I have made a repo with the code to reproduce the bug.

Thank you for this library and for the time and work you put into it btw, awesome job :)

ncruces commented 1 year ago

Thanks for the report and repro! Bug also affected macOS. Should be fixed in master, I'll tag a version later today.

In your repo I would advise checking the error here if you want to bail out early. Also, if you don't Close the dialog, it will be left open even after you return from main.

billy4479 commented 1 year ago

Should be fixed in master, I'll tag a version later today.

Awesome! thank you so much!

In your repo I would advise checking the error here if you want to bail out early. Also, if you don't Close the dialog, it will be left open even after you return from main.

Yes, thank you for mentioning it, it was just a quick hack to reproduce the panic. I'll update it for future reference.