Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Makes discord/lilliput segfault #93

Open
KernelDeimos opened this issue Aug 29, 2023 · 2 comments
Open

Makes discord/lilliput segfault #93

KernelDeimos opened this issue Aug 29, 2023 · 2 comments

Comments

@KernelDeimos
Copy link

KernelDeimos commented Aug 29, 2023

Simply importing go-fitz causes lilliput to segfault when it tries to resize an image. This is unfortunate because I'd like to use these two packages together.

I posted a duplicate issue on lilliput as well because I imagine it will take some investigation to determine the cause.

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

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
@gen2brain
Copy link
Owner

Without a GDB trace, it will be hard to find the exact reason. Anyway, I see a bunch of precompiled libraries here https://github.com/discord/lilliput/tree/master/deps/linux/lib, including FFmpeg, OpenCV, and all dependencies etc. go-fitz/mupdf does the similar with libmupdfthird which also includes libjpeg, harfbuzz etc. So, in the end, you get a mix of incompatible static libraries with probably different versions.
You can just use go-fitz with -tags extlib, i.e. external library, where bundled libraries will not be used, or check if that other library provides a way to use external and not bundled libraries.

@KernelDeimos
Copy link
Author

To make matters worse I was also doing a static build, which somehow I didn't think to mention here. I was trying to achieve a really small docker image using a mutli-stage build, which is what necessitated static linking. I've since given up again so I'll try this again later and see how it works out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants