probonopd / go-appimage

Go implementation of AppImage tools
MIT License
676 stars 69 forks source link

Crash when application has .svg instead of .png icon #285

Open Samueru-sama opened 2 months ago

Samueru-sama commented 2 months ago

I'm building an htop appimage and ran into this issue, it is caused because I'm using the included .svg as icon in the build, they also include a .png icon and when using the .png the issue doesn't happen.

I tested the continuos build and version 823, it happens with both. What's weird is that it only happens with this specific .svg icon as I haven't had this issue with other .svg in other appimages before.

Here is the error message:

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

goroutine 1 [running]:
github.com/rustyoz/genericlexer.Item.String({0x2, {0x0, 0x0}, 0x0, 0x0})
    github.com/rustyoz/genericlexer@v0.0.0-20190224115003-eb82fd2987bd/genericlexer.go:18 +0x77
github.com/rustyoz/svg.parseParenNumList(0xc000280000)
    github.com/rustyoz/svg@v0.0.0-20200706102315-fe1aeca2ba20/parser.go:157 +0x825
github.com/rustyoz/svg.parseTranslate(0x0?)
    github.com/rustyoz/svg@v0.0.0-20200706102315-fe1aeca2ba20/parser.go:100 +0x5b
github.com/rustyoz/svg.parseTransform({0xc000260260?, 0x7250f0?})
    github.com/rustyoz/svg@v0.0.0-20200706102315-fe1aeca2ba20/parser.go:69 +0x525
github.com/rustyoz/svg.(*Group).UnmarshalXML(0xc0001b3180, 0x27df98?, {{{0xc0002600a0, 0x1a}, {0xc1afb8, 0x1}}, {0xc00026aab0, 0x1, 0x1}})
    github.com/rustyoz/svg@v0.0.0-20200706102315-fe1aeca2ba20/svg.go:109 +0x70b
encoding/xml.(*Decoder).unmarshalInterface(0xc00022cea0, {0x7f5e026cfa28?, 0xc0001b3180}, 0xc0001fa838)
    encoding/xml/read.go:206 +0x1c3
encoding/xml.(*Decoder).unmarshal(0xc00022cea0, {0x2ea6a0?, 0xc0001b3180?, 0x0?}, 0x1a?, 0x0)
    encoding/xml/read.go:355 +0xf6a
encoding/xml.(*Decoder).DecodeElement(0xc00022cea0?, {0x27df60?, 0xc0001b3180?}, 0x7f5e036e4258?)
    encoding/xml/read.go:151 +0x111
github.com/rustyoz/svg.(*Svg).UnmarshalXML(0xc00011cb00, 0x27e018?, {{{0xc0002600a0, 0x1a}, {0xc0002330b6, 0x3}}, {0xc000198300, 0x6, 0x8}})
    github.com/rustyoz/svg@v0.0.0-20200706102315-fe1aeca2ba20/svg.go:224 +0x226
encoding/xml.(*Decoder).unmarshalInterface(0xc00022cea0, {0x7f5e026ca238?, 0xc00011cb00}, 0xc0002307c0)
    encoding/xml/read.go:206 +0x1c3
encoding/xml.(*Decoder).unmarshal(0xc00022cea0, {0x2e8200?, 0xc00011cb00?, 0xc00022b080?}, 0x0?, 0x0)
    encoding/xml/read.go:355 +0xf6a
encoding/xml.(*Decoder).DecodeElement(0x3f1f00?, {0x27dfe0?, 0xc00011cb00?}, 0x3?)
    encoding/xml/read.go:151 +0x111
encoding/xml.(*Decoder).Decode(...)
    encoding/xml/read.go:139
github.com/rustyoz/svg.ParseSvgFromReader({0x3f1f00, 0xc00022b080}, {0x0, 0x0}, 0x3ff0000000000000)
    github.com/rustyoz/svg@v0.0.0-20200706102315-fe1aeca2ba20/svg.go:296 +0x18e
github.com/mgord9518/imgconv.getSvgRes({0x3f1f00?, 0xc00022b080?})
    github.com/mgord9518/imgconv@v0.0.0-20211227113402-4a8e0ad15713/imgconv.go:320 +0x36
github.com/mgord9518/imgconv.ConvertWithAspect({0x3f2280?, 0xc000010838}, 0x100, {0x305e5d, 0x3})
    github.com/mgord9518/imgconv@v0.0.0-20211227113402-4a8e0ad15713/imgconv.go:75 +0x2c5
github.com/mgord9518/imgconv.ConvertFileWithAspect({0xc00002b4a0?, 0x7ffd2[588](https://github.com/Samueru-sama/htop-AppImage/actions/runs/8905425571/job/24456110434#step:3:589)7c87?}, {0xc00002b530, 0x14}, 0x0?, {0x305e5d, 0x3})
    github.com/mgord9518/imgconv@v0.0.0-20211227113402-4a8e0ad15713/imgconv.go:91 +0x78
main.GenerateAppImage({0x7ffd25887c87, 0xb}, {0x0, 0x0}, 0x1, {0x0, 0x0}, {0x306b13, 0x4}, 0x1, ...)
    github.com/probonopd/go-appimage/src/appimagetool/appimagetool.go:355 +0x14cc
main.bootstrapAppImageBuild(0xc0002301c0)
    github.com/probonopd/go-appimage/src/appimagetool/cli.go:167 +0x1e5
github.com/urfave/cli/v2.(*App).RunContext(0xc000168380, {0x3f5c98?, 0xc000026190}, {0xc000020180, 0x3, 0x3})
    github.com/urfave/cli/v2@v2.17.1/app.go:395 +0xfbf
github.com/urfave/cli/v2.(*App).Run(...)
    github.com/urfave/cli/v2@v2.17.1/app.go:252
main.main()
    github.com/probonopd/go-appimage/src/appimagetool/cli.go:288 +0x6df

And here is the script that is being used for the build: https://github.com/Samueru-sama/htop-AppImage/blob/main/htop-appimage.sh

Commenting out line 18 (+ commenting line 19) will cause appimagetool to fail when trying to make the appimage.

I get the same error when trying the script on my pc so it is not limited to the ubuntu runner.

probonopd commented 2 months ago

At this point I think we should just use the png and delete the svg. svg parsing is just too difficult...

Samueru-sama commented 2 months ago

At this point I think we should just use the png and delete the svg. svg parsing is just too difficult...

Can't there be a function that converts the svg to png for programs that don't ship a png in their builds?

probonopd commented 1 month ago

That'd be ImageMagick I guess. You can run it before running fo-appimage's appimagetool deploy.

probonopd commented 1 month ago

This being said, we should make a nice error handler instead of just crashing.