discord / lilliput

Resize images and animated GIFs in Go
https://discord.com/blog/how-discord-resizes-150-million-images-every-day-with-go-and-c
Other
1.94k stars 124 forks source link

Segfaults when `go-fitz` is imported #132

Open KernelDeimos opened 10 months ago

KernelDeimos commented 10 months ago

Simply importing go-fitz causes Lilliput to segfault when trying to resize an image. This is unfortunate because I'd like to use these two packages together, and also because I didn't expect golang to hurt me like this.

I put a duplicate issue on go-fitz as well because I imagine it will take some investigation to determine where the cause lies.

Here's the stack trace immediately following my call to .Transform(...) on a ImageOps:

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xa2f393]

runtime stack:
runtime.throw({0x1897f26?, 0x7f33b4000030?})
    /usr/local/go/src/runtime/panic.go:1047 +0x5d fp=0x7f33c37fd190 sp=0x7f33c37fd160 pc=0x45931d
runtime.sigpanic()
    /usr/local/go/src/runtime/signal_unix.go:825 +0x3e9 fp=0x7f33c37fd1f0 sp=0x7f33c37fd190 pc=0x46f7c9

goroutine 7 [syscall]:
runtime.cgocall(0x80bb40, 0xc0003c2b18)
    /usr/local/go/src/runtime/cgocall.go:157 +0x5c fp=0xc0003c2af0 sp=0xc0003c2ab8 pc=0x427f9c
github.com/discord/lilliput._Cfunc_opencv_encoder_write(0x7f33b4001760, 0x7f33b4000f90, 0xc0004866f0, 0x2)
    _cgo_gotypes.go:690 +0x49 fp=0xc0003c2b18 sp=0xc0003c2af0 pc=0x7ff429
github.com/discord/lilliput.(*openCVEncoder).Encode.func1(0xc0003c2bd0?, 0xc000496000?, 0xc0003c2bd0?, {0xc0004866f0?, 0x2, 0x802a3b?})
    /go/pkg/mod/github.com/discord/lilliput@v0.0.0-20230714032231-217a9d5cff47/opencv.go:596 +0x91 fp=0xc0003c2b68 sp=0xc0003c2b18 pc=0x8046b1
github.com/discord/lilliput.(*openCVEncoder).Encode(0xc000497f20, 0xc010528040, 0xc010528000?)
    /go/pkg/mod/github.com/discord/lilliput@v0.0.0-20230714032231-217a9d5cff47/opencv.go:596 +0x185 fp=0xc0003c2c40 sp=0xc0003c2b68 pc=0x804425
github.com/discord/lilliput.(*ImageOps).encode(0xc00046a000?, {0x193a1d8?, 0xc000497f20?}, 0xc000497e60?)
    /go/pkg/mod/github.com/discord/lilliput@v0.0.0-20230714032231-217a9d5cff47/ops.go:126 +0x3e fp=0xc0003c2c68 sp=0xc0003c2c40 pc=0x7fd1be
github.com/discord/lilliput.(*ImageOps).Transform(0xc00046a000, {0x193ca88, 0xc000497e60}, 0xc000492000, {0xc020600000, 0x3200000, 0x3200000})
    /go/pkg/mod/github.com/discord/lilliput@v0.0.0-20230714032231-217a9d5cff47/ops.go:204 +0x3c5 fp=0xc0003c2d40 sp=0xc0003c2c68 pc=0x7fd5e5