davidbyttow / govips

A lightning fast image processing and resizing library for Go
MIT License
1.29k stars 199 forks source link

cgo crashes on libvips 8.14.2_1 #356

Open AttilaTheFun opened 1 year ago

AttilaTheFun commented 1 year ago

I'm getting this cgo crash when running tests against libvips 8.14.2_1 I installed this version on an M1 Max MacBook Pro through homebrew. My Go version is 1.19.2, also installed through homebrew.

I also got the same crash when running TestImageRef_Orientation_Issue.

=== RUN   TestImage_GIF_Animated_to_WebP
2023/05/04 15:55:54 [govips.info] warning libvips already started
fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x2 addr=0x0 pc=0x10499d92c]

runtime stack:
runtime.throw({0x104246e06?, 0x16bdca340?})
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/panic.go:1047 +0x40 fp=0x16bdca310 sp=0x16bdca2e0 pc=0x10406d8a0
runtime.sigpanic()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/signal_unix.go:819 +0x1e4 fp=0x16bdca340 sp=0x16bdca310 pc=0x104084944

goroutine 40 [syscall]:
runtime.cgocall(0x10422d9ac, 0x14000052a38)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/cgocall.go:158 +0x54 fp=0x14000052a00 sp=0x140000529c0 pc=0x10403ab84
github.com/davidbyttow/govips/v2/vips._Cfunc_save_to_buffer(0x140001b40c0)
    _cgo_gotypes.go:2017 +0x38 fp=0x14000052a30 sp=0x14000052a00 pc=0x104216cb8
github.com/davidbyttow/govips/v2/vips.vipsSaveToBuffer.func1(0x14000052ab8?)
    /Users/logan/Developer/Go/govips/vips/foreign.go:464 +0x58 fp=0x14000052a70 sp=0x14000052a30 pc=0x10421ff88
github.com/davidbyttow/govips/v2/vips.vipsSaveToBuffer({0x123e06000, 0x0, 0x2, 0x0, 0x0, 0x4b, 0x0, 0x0, 0x1, 0x0, ...})
    /Users/logan/Developer/Go/govips/vips/foreign.go:464 +0x88 fp=0x14000052af0 sp=0x14000052a70 pc=0x10421fd68
github.com/davidbyttow/govips/v2/vips.vipsSaveWebPToBuffer(0x123e06000, {0x0, 0x4b, 0x0, 0x0, 0x4, {0x0, 0x0}})
    /Users/logan/Developer/Go/govips/vips/foreign.go:386 +0x12c fp=0x14000052cd0 sp=0x14000052af0 pc=0x10421f52c
github.com/davidbyttow/govips/v2/vips.(*ImageRef).ExportWebp(0x140001b20f0, 0x1400077c1c0?)
    /Users/logan/Developer/Go/govips/vips/image.go:924 +0x98 fp=0x14000052d90 sp=0x14000052cd0 pc=0x1042251f8
github.com/davidbyttow/govips/v2/vips.exportWebp.func1(0x104316328?)
    /Users/logan/Developer/Go/govips/vips/image_golden_test.go:905 +0x20 fp=0x14000052db0 sp=0x14000052d90 pc=0x10420aea0
github.com/davidbyttow/govips/v2/vips.goldenAnimatedTest(0x140007622d0?, {0x104241992, 0x1d}, 0x140398aa6e0?, 0x398aa6e000000000?, 0x64540dca?, 0x1400074b758?)
    /Users/logan/Developer/Go/govips/vips/image_golden_test.go:1123 +0x14c fp=0x14000052f10 sp=0x14000052db0 pc=0x10420beec
github.com/davidbyttow/govips/v2/vips.TestImage_GIF_Animated_to_WebP(0x0?)
    /Users/logan/Developer/Go/govips/vips/image_gif_test.go:36 +0x64 fp=0x14000052f60 sp=0x14000052f10 pc=0x104203984
testing.tRunner(0x14000082d00, 0x104313358)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/testing/testing.go:1446 +0x10c fp=0x14000052fb0 sp=0x14000052f60 pc=0x10410f1bc
testing.(*T).Run.func1()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/testing/testing.go:1493 +0x2c fp=0x14000052fd0 sp=0x14000052fb0 pc=0x10410fefc
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000052fd0 sp=0x14000052fd0 pc=0x1040a0034
created by testing.(*T).Run
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/testing/testing.go:1493 +0x300

goroutine 1 [chan receive]:
runtime.gopark(0x140001299c8?, 0x10410c278?, 0x28?, 0x9a?, 0x10404438c?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x140001299a0 sp=0x14000129980 pc=0x104070284
runtime.chanrecv(0x14000092070, 0x14000129aaf, 0x1)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/chan.go:583 +0x454 fp=0x14000129a30 sp=0x140001299a0 pc=0x10403d8e4
runtime.chanrecv1(0x104242325?, 0x104242325?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/chan.go:442 +0x14 fp=0x14000129a60 sp=0x14000129a30 pc=0x10403d484
testing.(*T).Run(0x140001609c0, {0x104242325?, 0x1d6c42218d2ab?}, 0x104313358)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/testing/testing.go:1494 +0x314 fp=0x14000129b00 sp=0x14000129a60 pc=0x10410fe54
testing.runTests.func1(0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/testing/testing.go:1846 +0x70 fp=0x14000129b50 sp=0x14000129b00 pc=0x104111b10
testing.tRunner(0x140001609c0, 0x14000137c68)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/testing/testing.go:1446 +0x10c fp=0x14000129ba0 sp=0x14000129b50 pc=0x10410f1bc
testing.runTests(0x14000117220?, {0x104543a80, 0xc2, 0xc2}, {0x104640108?, 0x40?, 0x104547ec0?})
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/testing/testing.go:1844 +0x3f0 fp=0x14000129c90 sp=0x14000129ba0 pc=0x1041119d0
testing.(*M).Run(0x14000117220)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/testing/testing.go:1726 +0x4f0 fp=0x14000129e90 sp=0x14000129c90 pc=0x104110770
github.com/davidbyttow/govips/v2/vips.TestMain(0x14000052ec8?)
    /Users/logan/Developer/Go/govips/vips/image_test.go:18 +0x1c fp=0x14000129eb0 sp=0x14000129e90 pc=0x10420c00c
main.main()
    _testmain.go:439 +0x1d4 fp=0x14000129f70 sp=0x14000129eb0 pc=0x10422c6a4
runtime.main()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:250 +0x24c fp=0x14000129fd0 sp=0x14000129f70 pc=0x10406febc
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000129fd0 sp=0x14000129fd0 pc=0x1040a0034

goroutine 2 [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000044fa0 sp=0x14000044f80 pc=0x104070284
runtime.goparkunlock(...)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:369
runtime.forcegchelper()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:302 +0xac fp=0x14000044fd0 sp=0x14000044fa0 pc=0x10407011c
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000044fd0 sp=0x14000044fd0 pc=0x1040a0034
created by runtime.init.6
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:290 +0x24

goroutine 18 [GC sweep wait]:
runtime.gopark(0x1?, 0x0?, 0x0?, 0x0?, 0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000040770 sp=0x14000040750 pc=0x104070284
runtime.goparkunlock(...)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:369
runtime.bgsweep(0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgcsweep.go:297 +0x10c fp=0x140000407b0 sp=0x14000040770 pc=0x10405b79c
runtime.gcenable.func1()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:178 +0x28 fp=0x140000407d0 sp=0x140000407b0 pc=0x10404fcf8
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000407d0 sp=0x140000407d0 pc=0x1040a0034
created by runtime.gcenable
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:178 +0x74

goroutine 19 [sleep]:
runtime.gopark(0x140000120a0?, 0x1d6c488e386f5?, 0x0?, 0x0?, 0x104313b28?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000040f00 sp=0x14000040ee0 pc=0x104070284
runtime.goparkunlock(...)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:369
runtime.(*scavengerState).sleep(0x104547f40, 0x40d5320000000000)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgcscavenge.go:468 +0x134 fp=0x14000040f80 sp=0x14000040f00 pc=0x1040598f4
runtime.bgscavenge(0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgcscavenge.go:626 +0x9c fp=0x14000040fb0 sp=0x14000040f80 pc=0x104059cec
runtime.gcenable.func2()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:179 +0x28 fp=0x14000040fd0 sp=0x14000040fb0 pc=0x10404fc98
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000040fd0 sp=0x14000040fd0 pc=0x1040a0034
created by runtime.gcenable
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:179 +0xb8

goroutine 3 [finalizer wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000045580 sp=0x14000045560 pc=0x104070284
runtime.goparkunlock(...)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:369
runtime.runfinq()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mfinal.go:180 +0x120 fp=0x140000457d0 sp=0x14000045580 pc=0x10404eea0
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000457d0 sp=0x140000457d0 pc=0x1040a0034
created by runtime.createfing
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mfinal.go:157 +0x84

goroutine 9 [GC worker (idle)]:
runtime.gopark(0x14000161520?, 0x10410f168?, 0xa8?, 0x5f?, 0x10410fefc?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000045f40 sp=0x14000045f20 pc=0x104070284
runtime.gcBgMarkWorker()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1235 +0xec fp=0x14000045fd0 sp=0x14000045f40 pc=0x1040520dc
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000045fd0 sp=0x14000045fd0 pc=0x1040a0034
created by runtime.gcBgMarkStartWorkers
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1159 +0x28

goroutine 20 [GC worker (idle)]:
runtime.gopark(0x0?, 0x2?, 0x20?, 0xc6?, 0x1400008e000?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000044740 sp=0x14000044720 pc=0x104070284
runtime.gcBgMarkWorker()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1235 +0xec fp=0x140000447d0 sp=0x14000044740 pc=0x1040520dc
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000447d0 sp=0x140000447d0 pc=0x1040a0034
created by runtime.gcBgMarkStartWorkers
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1159 +0x28

goroutine 10 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000046740 sp=0x14000046720 pc=0x104070284
runtime.gcBgMarkWorker()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1235 +0xec fp=0x140000467d0 sp=0x14000046740 pc=0x1040520dc
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000467d0 sp=0x140000467d0 pc=0x1040a0034
created by runtime.gcBgMarkStartWorkers
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1159 +0x28

goroutine 34 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x1400074e740 sp=0x1400074e720 pc=0x104070284
runtime.gcBgMarkWorker()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1235 +0xec fp=0x1400074e7d0 sp=0x1400074e740 pc=0x1040520dc
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x1400074e7d0 sp=0x1400074e7d0 pc=0x1040a0034
created by runtime.gcBgMarkStartWorkers
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1159 +0x28

goroutine 11 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000046f40 sp=0x14000046f20 pc=0x104070284
runtime.gcBgMarkWorker()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1235 +0xec fp=0x14000046fd0 sp=0x14000046f40 pc=0x1040520dc
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000046fd0 sp=0x14000046fd0 pc=0x1040a0034
created by runtime.gcBgMarkStartWorkers
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1159 +0x28

goroutine 35 [GC worker (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x1400074ef40 sp=0x1400074ef20 pc=0x104070284
runtime.gcBgMarkWorker()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1235 +0xec fp=0x1400074efd0 sp=0x1400074ef40 pc=0x1040520dc
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x1400074efd0 sp=0x1400074efd0 pc=0x1040a0034
created by runtime.gcBgMarkStartWorkers
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1159 +0x28

goroutine 12 [GC worker (idle)]:
runtime.gopark(0x1d6c42350a16c?, 0x0?, 0x0?, 0x0?, 0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000047740 sp=0x14000047720 pc=0x104070284
runtime.gcBgMarkWorker()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1235 +0xec fp=0x140000477d0 sp=0x14000047740 pc=0x1040520dc
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000477d0 sp=0x140000477d0 pc=0x1040a0034
created by runtime.gcBgMarkStartWorkers
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1159 +0x28

goroutine 21 [GC worker (idle)]:
runtime.gopark(0x104578d40?, 0x1?, 0x25?, 0x5b?, 0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000041740 sp=0x14000041720 pc=0x104070284
runtime.gcBgMarkWorker()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1235 +0xec fp=0x140000417d0 sp=0x14000041740 pc=0x1040520dc
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x140000417d0 sp=0x140000417d0 pc=0x1040a0034
created by runtime.gcBgMarkStartWorkers
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1159 +0x28

goroutine 36 [GC worker (idle)]:
runtime.gopark(0x1d6c42350ead3?, 0x1?, 0x9b?, 0x2?, 0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x1400074f740 sp=0x1400074f720 pc=0x104070284
runtime.gcBgMarkWorker()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1235 +0xec fp=0x1400074f7d0 sp=0x1400074f740 pc=0x1040520dc
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x1400074f7d0 sp=0x1400074f7d0 pc=0x1040a0034
created by runtime.gcBgMarkStartWorkers
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1159 +0x28

goroutine 13 [GC worker (idle)]:
runtime.gopark(0x1d6c423510b61?, 0x0?, 0x0?, 0x0?, 0x0?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000047f40 sp=0x14000047f20 pc=0x104070284
runtime.gcBgMarkWorker()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1235 +0xec fp=0x14000047fd0 sp=0x14000047f40 pc=0x1040520dc
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000047fd0 sp=0x14000047fd0 pc=0x1040a0034
created by runtime.gcBgMarkStartWorkers
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/mgc.go:1159 +0x28

goroutine 23 [select]:
runtime.gopark(0x14000750fa8?, 0x2?, 0x48?, 0xe?, 0x14000750f74?)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:363 +0xe4 fp=0x14000750e10 sp=0x14000750df0 pc=0x104070284
runtime.selectgo(0x14000750fa8, 0x14000750f70, 0x10423b859?, 0x0, 0x14000750fa8?, 0x1)
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/select.go:328 +0x688 fp=0x14000750f30 sp=0x14000750e10 pc=0x104080b78
github.com/davidbyttow/govips/v2/vips.collectStats.func1()
    /Users/logan/Developer/Go/govips/vips/stats.go:28 +0x84 fp=0x14000750fd0 sp=0x14000750f30 pc=0x1042025e4
runtime.goexit()
    /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 +0x4 fp=0x14000750fd0 sp=0x14000750fd0 pc=0x1040a0034
created by github.com/davidbyttow/govips/v2/vips.collectStats
    /Users/logan/Developer/Go/govips/vips/stats.go:26 +0xd4
FAIL    github.com/davidbyttow/govips/v2/vips   0.081s
Delicious-Bacon commented 1 year ago

This isn't anything new, cgo crashes have been around for a while now: #291