Closed rtcrocker closed 3 months ago
Here's that code (as a .zip file). imagickPdfSIGABRT.zip
TLDR: There's something about the 2nd PDF file (40018423005.pdf
) that seems to trigger the failure mode.
When I run it on my Mac, I get this output:
% make demo
CGO_ENABLED=1 go build -o ./demo .
./demo
2024-07-22T17:27:49.693-0700 INFO imagickPdfSIGABRT/main.go:27 Starting
2024-07-22T17:27:49.700-0700 INFO imagickPdfSIGABRT/main.go:64 First few bytes of image data {"imagePath": "jpg-24bit-icc-adobe-rgb.jpg", "len": 1297581, "data": "ffd8ffe120e545786966000049492a0008000000"}
2024-07-22T17:27:49.732-0700 INFO imagickPdfSIGABRT/main.go:71 image properties {"imagePath": "jpg-24bit-icc-adobe-rgb.jpg", "width": 1900, "height": 1263, "frames": 1, "kind": "JPEG"}
2024-07-22T17:27:49.732-0700 INFO imagickPdfSIGABRT/main.go:64 First few bytes of image data {"imagePath": "sample1.heic", "len": 293608, "data": "00000018667479706d696631000000006d696631"}
2024-07-22T17:27:49.815-0700 INFO imagickPdfSIGABRT/main.go:71 image properties {"imagePath": "sample1.heic", "width": 1440, "height": 960, "frames": 1, "kind": "HEIC"}
2024-07-22T17:27:49.815-0700 INFO imagickPdfSIGABRT/main.go:64 First few bytes of image data {"imagePath": "8Pages.pdf", "len": 206723, "data": "255044462d312e330d25e2e3cfd30d0a37312030"}
2024-07-22T17:27:50.645-0700 INFO imagickPdfSIGABRT/main.go:71 image properties {"imagePath": "8Pages.pdf", "width": 612, "height": 792, "frames": 8, "kind": "PDF"}
2024-07-22T17:27:50.645-0700 INFO imagickPdfSIGABRT/main.go:64 First few bytes of image data {"imagePath": "40018423005.pdf", "len": 1299285, "data": "255044462d312e330a25c4e5f2e5eba7f3a0d0c4"}
2024-07-22T17:27:50.801-0700 INFO imagickPdfSIGABRT/main.go:71 image properties {"imagePath": "40018423005.pdf", "width": 612, "height": 792, "frames": 1, "kind": "PDF"}
2024-07-22T17:27:50.801-0700 INFO imagickPdfSIGABRT/main.go:35 Ending
When I run it via the container, I get this output:
% make docker-run
docker run sigabrt-demo
2024-07-23T00:29:03.269Z INFO app/main.go:27 Starting
2024-07-23T00:29:03.271Z INFO app/main.go:64 First few bytes of image data {"imagePath": "jpg-24bit-icc-adobe-rgb.jpg", "len": 1297581, "data": "ffd8ffe120e545786966000049492a0008000000"}
2024-07-23T00:29:03.318Z INFO app/main.go:71 image properties {"imagePath": "jpg-24bit-icc-adobe-rgb.jpg", "width": 1900, "height": 1263, "frames": 1, "kind": "JPEG"}
2024-07-23T00:29:03.319Z INFO app/main.go:64 First few bytes of image data {"imagePath": "sample1.heic", "len": 293608, "data": "00000018667479706d696631000000006d696631"}
2024-07-23T00:29:03.417Z INFO app/main.go:71 image properties {"imagePath": "sample1.heic", "width": 1440, "height": 960, "frames": 1, "kind": "HEIC"}
2024-07-23T00:29:03.417Z INFO app/main.go:64 First few bytes of image data {"imagePath": "8Pages.pdf", "len": 206723, "data": "255044462d312e330d25e2e3cfd30d0a37312030"}
2024-07-23T00:29:03.799Z INFO app/main.go:71 image properties {"imagePath": "8Pages.pdf", "width": 612, "height": 792, "frames": 8, "kind": "PDF"}
2024-07-23T00:29:03.799Z INFO app/main.go:64 First few bytes of image data {"imagePath": "40018423005.pdf", "len": 1299285, "data": "255044462d312e330a25c4e5f2e5eba7f3a0d0c4"}
demo: MagickCore/string.c:1200: GetStringInfoDatum: Assertion `string_info->signature == MagickCoreSignature' failed.
SIGABRT: abort
PC=0xffffa2300a10 m=0 sigcode=18446744073709551610
signal arrived during cgo execution
goroutine 1 gp=0x40000021c0 m=0 mp=0x72ce00 [syscall]:
runtime.cgocall(0x556f40, 0x400001dab8)
/usr/local/go/src/runtime/cgocall.go:157 +0x44 fp=0x400001da80 sp=0x400001da40 pc=0x411844
gopkg.in/gographics/imagick.v3/imagick._Cfunc_MagickReadImageBlob(0x6c07350, 0x400033a000, 0x13d355)
_cgo_gotypes.go:6700 +0x34 fp=0x400001dab0 sp=0x400001da80 pc=0x54f734
gopkg.in/gographics/imagick.v3/imagick.(*MagickWand).ReadImageBlob.func1(0x400001db48?, 0x400001db60)
/go/pkg/mod/gopkg.in/gographics/imagick.v3@v3.7.0/imagick/magick_wand_image.go:1942 +0xb0 fp=0x400001db20 sp=0x400001dab0 pc=0x550700
gopkg.in/gographics/imagick.v3/imagick.(*MagickWand).ReadImageBlob(0x400009c090, {0x400033a000, 0x13d355, 0x13d356})
/go/pkg/mod/gopkg.in/gographics/imagick.v3@v3.7.0/imagick/magick_wand_image.go:1942 +0x34 fp=0x400001db50 sp=0x400001db20 pc=0x5505b4
main.getImageProperties({0x400033a000, 0x13d355, 0x13d356})
/app/main.go:85 +0x84 fp=0x400001dc00 sp=0x400001db50 pc=0x551514
main.getImageInfo({0x5af248, 0xf})
/app/main.go:70 +0x3c0 fp=0x400001def0 sp=0x400001dc00 pc=0x5511c0
main.main()
/app/main.go:32 +0x9c fp=0x400001df40 sp=0x400001def0 pc=0x550aac
runtime.main()
/usr/local/go/src/runtime/proc.go:271 +0x28c fp=0x400001dfd0 sp=0x400001df40 pc=0x44711c
runtime.goexit({})
/usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x400001dfd0 sp=0x400001dfd0 pc=0x4795b4
goroutine 2 gp=0x4000002c40 m=nil [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:402 +0xc8 fp=0x4000046f90 sp=0x4000046f70 pc=0x447548
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:408
runtime.forcegchelper()
/usr/local/go/src/runtime/proc.go:326 +0xb8 fp=0x4000046fd0 sp=0x4000046f90 pc=0x4473d8
runtime.goexit({})
/usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x4000046fd0 sp=0x4000046fd0 pc=0x4795b4
created by runtime.init.6 in goroutine 1
/usr/local/go/src/runtime/proc.go:314 +0x24
goroutine 3 gp=0x4000003180 m=nil [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:402 +0xc8 fp=0x4000047760 sp=0x4000047740 pc=0x447548
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:408
runtime.bgsweep(0x4000070000)
/usr/local/go/src/runtime/mgcsweep.go:278 +0xa0 fp=0x40000477b0 sp=0x4000047760 pc=0x432d90
runtime.gcenable.gowrap1()
/usr/local/go/src/runtime/mgc.go:203 +0x28 fp=0x40000477d0 sp=0x40000477b0 pc=0x427218
runtime.goexit({})
/usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x40000477d0 sp=0x40000477d0 pc=0x4795b4
created by runtime.gcenable in goroutine 1
/usr/local/go/src/runtime/mgc.go:203 +0x6c
goroutine 4 gp=0x4000003340 m=nil [GC scavenge wait]:
runtime.gopark(0x4000070000?, 0x5ff5b8?, 0x1?, 0x0?, 0x4000003340?)
/usr/local/go/src/runtime/proc.go:402 +0xc8 fp=0x4000047f60 sp=0x4000047f40 pc=0x447548
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:408
runtime.(*scavengerState).park(0x72c720)
/usr/local/go/src/runtime/mgcscavenge.go:425 +0x5c fp=0x4000047f90 sp=0x4000047f60 pc=0x43078c
runtime.bgscavenge(0x4000070000)
/usr/local/go/src/runtime/mgcscavenge.go:653 +0x44 fp=0x4000047fb0 sp=0x4000047f90 pc=0x430cd4
runtime.gcenable.gowrap2()
/usr/local/go/src/runtime/mgc.go:204 +0x28 fp=0x4000047fd0 sp=0x4000047fb0 pc=0x4271b8
runtime.goexit({})
/usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x4000047fd0 sp=0x4000047fd0 pc=0x4795b4
created by runtime.gcenable in goroutine 1
/usr/local/go/src/runtime/mgc.go:204 +0xac
goroutine 5 gp=0x4000003c00 m=nil [finalizer wait]:
runtime.gopark(0x0?, 0x0?, 0xb8?, 0x65?, 0x475534?)
/usr/local/go/src/runtime/proc.go:402 +0xc8 fp=0x4000046580 sp=0x4000046560 pc=0x447548
runtime.runfinq()
/usr/local/go/src/runtime/mfinal.go:194 +0x108 fp=0x40000467d0 sp=0x4000046580 pc=0x4262e8
runtime.goexit({})
/usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x40000467d0 sp=0x40000467d0 pc=0x4795b4
created by runtime.createfing in goroutine 1
/usr/local/go/src/runtime/mfinal.go:164 +0x80
r0 0x0
r1 0x1
r2 0x6
r3 0xffffa2277020
r4 0xffffa2a2db88
r5 0x1
r6 0x20
r7 0x3e73543b03928d8a
r8 0x83
r9 0x203a303032313a63
r10 0x636967614d203d3d
r11 0x67695365726f436b
r12 0x2180
r13 0xa2e64656c696166
r14 0x6e69727453746547
r15 0x7461446f666e4967
r16 0x1
r17 0xffffa230f654
r18 0x5
r19 0x1
r20 0xffffa2277020
r21 0x6
r22 0xffffa274eeb8
r23 0x4b0
r24 0x6db6d50
r25 0xffffcb673de0
r26 0xffffcb671d30
r27 0x6db4ae0
r28 0x72ec030
r29 0xffffcb671a60
lr 0xffffa23009fc
sp 0xffffcb671a60
pc 0xffffa2300a10
fault 0x0
make: *** [docker-run] Error 2
Mac version of imagemagick:
% magick -version
Version: ImageMagick 7.1.1-34 Q16-HDRI aarch64 22301 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenMP(5.0)
Delegates (built-in): bzlib fontconfig freetype gslib heic jng jp2 jpeg jxl lcms lqr ltdl lzma openexr png ps raw tiff webp xml zlib zstd
Compiler: gcc (4.2)
Same command inside the container:
% docker run --entrypoint magick sigabrt-demo -version
Version: ImageMagick 7.1.1-34 Q16-HDRI aarch64 39a4f1cb2:20240623 https://imagemagick.org
Copyright: (C) 1999 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.5)
Delegates (built-in): fontconfig freetype gslib heic jbig jng jpeg lcms lzma png ps raw tiff webp x zlib zstd
Compiler: gcc (12.2)
Does it crash in any other docker image types? I see you are using the go-1.22 as a builder but not ultimately running it in a different image. If it does not crash when run natively on your mac, but does crash when run inside of a container, there could be something wrong with one of the delegate plugins that handle the pdf (ghostscript, etc?).
@justinfx Thanks for following up. It does not crash with either jpg or heic. I added a gif and png to the test - this is the container output:
% make docker-run
docker run sigabrt-demo
2024-07-23T03:38:19.738Z INFO app/main.go:29 Starting
2024-07-23T03:38:19.739Z INFO app/main.go:66 First few bytes of image data {"imagePath": "jpg-24bit-icc-adobe-rgb.jpg", "len": 1297581, "data": "ffd8ffe120e545786966000049492a0008000000"}
2024-07-23T03:38:19.759Z INFO app/main.go:73 image properties {"imagePath": "jpg-24bit-icc-adobe-rgb.jpg", "width": 1900, "height": 1263, "frames": 1, "kind": "JPEG"}
2024-07-23T03:38:19.759Z INFO app/main.go:66 First few bytes of image data {"imagePath": "sample1.heic", "len": 293608, "data": "00000018667479706d696631000000006d696631"}
2024-07-23T03:38:19.853Z INFO app/main.go:73 image properties {"imagePath": "sample1.heic", "width": 1440, "height": 960, "frames": 1, "kind": "HEIC"}
2024-07-23T03:38:19.853Z INFO app/main.go:66 First few bytes of image data {"imagePath": "8Pages.pdf", "len": 206723, "data": "255044462d312e330d25e2e3cfd30d0a37312030"}
2024-07-23T03:38:20.261Z INFO app/main.go:73 image properties {"imagePath": "8Pages.pdf", "width": 612, "height": 792, "frames": 8, "kind": "PDF"}
2024-07-23T03:38:20.261Z INFO app/main.go:66 First few bytes of image data {"imagePath": "img.png", "len": 2990, "data": "89504e470d0a1a0a0000000d4948445200000190"}
2024-07-23T03:38:20.261Z INFO app/main.go:73 image properties {"imagePath": "img.png", "width": 400, "height": 300, "frames": 1, "kind": "PNG"}
2024-07-23T03:38:20.261Z INFO app/main.go:66 First few bytes of image data {"imagePath": "animated.gif", "len": 178668, "data": "47494638396190012c01f41800000000223822a5"}
2024-07-23T03:38:20.292Z INFO app/main.go:73 image properties {"imagePath": "animated.gif", "width": 400, "height": 300, "frames": 36, "kind": "GIF"}
2024-07-23T03:38:20.292Z INFO app/main.go:66 First few bytes of image data {"imagePath": "40018423005.pdf", "len": 1299285, "data": "255044462d312e330a25c4e5f2e5eba7f3a0d0c4"}
demo: MagickCore/string.c:1200: GetStringInfoDatum: Assertion `string_info->signature == MagickCoreSignature' failed.
SIGABRT: abort
PC=0xffffbc100a10 m=0 sigcode=18446744073709551610
signal arrived during cgo execution
goroutine 1 gp=0x40000021c0 m=0 mp=0x72ce20 [syscall]:
runtime.cgocall(0x556f40, 0x400001dab8)
/usr/local/go/src/runtime/cgocall.go:157 +0x44 fp=0x400001da80 sp=0x400001da40 pc=0x411844
gopkg.in/gographics/imagick.v3/imagick._Cfunc_MagickReadImageBlob(0x1fdbf350, 0x4000328000, 0x13d355)
_cgo_gotypes.go:6700 +0x34 fp=0x400001dab0 sp=0x400001da80 pc=0x54f734
gopkg.in/gographics/imagick.v3/imagick.(*MagickWand).ReadImageBlob.func1(0x400001db48?, 0x400001db60)
/go/pkg/mod/gopkg.in/gographics/imagick.v3@v3.7.0/imagick/magick_wand_image.go:1942 +0xb0 fp=0x400001db20 sp=0x400001dab0 pc=0x550700
gopkg.in/gographics/imagick.v3/imagick.(*MagickWand).ReadImageBlob(0x40000e6150, {0x4000328000, 0x13d355, 0x13d356})
/go/pkg/mod/gopkg.in/gographics/imagick.v3@v3.7.0/imagick/magick_wand_image.go:1942 +0x34 fp=0x400001db50 sp=0x400001db20 pc=0x5505b4
main.getImageProperties({0x4000328000, 0x13d355, 0x13d356})
/app/main.go:87 +0x84 fp=0x400001dc00 sp=0x400001db50 pc=0x551514
main.getImageInfo({0x5af25b, 0xf})
/app/main.go:72 +0x3c0 fp=0x400001def0 sp=0x400001dc00 pc=0x5511c0
main.main()
/app/main.go:34 +0x9c fp=0x400001df40 sp=0x400001def0 pc=0x550aac
runtime.main()
/usr/local/go/src/runtime/proc.go:271 +0x28c fp=0x400001dfd0 sp=0x400001df40 pc=0x44711c
runtime.goexit({})
/usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x400001dfd0 sp=0x400001dfd0 pc=0x4795b4
goroutine 2 gp=0x4000002c40 m=nil [force gc (idle)]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:402 +0xc8 fp=0x4000046f90 sp=0x4000046f70 pc=0x447548
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:408
runtime.forcegchelper()
/usr/local/go/src/runtime/proc.go:326 +0xb8 fp=0x4000046fd0 sp=0x4000046f90 pc=0x4473d8
runtime.goexit({})
/usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x4000046fd0 sp=0x4000046fd0 pc=0x4795b4
created by runtime.init.6 in goroutine 1
/usr/local/go/src/runtime/proc.go:314 +0x24
goroutine 3 gp=0x4000003180 m=nil [GC sweep wait]:
runtime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)
/usr/local/go/src/runtime/proc.go:402 +0xc8 fp=0x4000047760 sp=0x4000047740 pc=0x447548
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:408
runtime.bgsweep(0x4000070000)
/usr/local/go/src/runtime/mgcsweep.go:278 +0xa0 fp=0x40000477b0 sp=0x4000047760 pc=0x432d90
runtime.gcenable.gowrap1()
/usr/local/go/src/runtime/mgc.go:203 +0x28 fp=0x40000477d0 sp=0x40000477b0 pc=0x427218
runtime.goexit({})
/usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x40000477d0 sp=0x40000477d0 pc=0x4795b4
created by runtime.gcenable in goroutine 1
/usr/local/go/src/runtime/mgc.go:203 +0x6c
goroutine 4 gp=0x4000003340 m=nil [GC scavenge wait]:
runtime.gopark(0x4000070000?, 0x5ff5b8?, 0x1?, 0x0?, 0x4000003340?)
/usr/local/go/src/runtime/proc.go:402 +0xc8 fp=0x4000047f60 sp=0x4000047f40 pc=0x447548
runtime.goparkunlock(...)
/usr/local/go/src/runtime/proc.go:408
runtime.(*scavengerState).park(0x72c740)
/usr/local/go/src/runtime/mgcscavenge.go:425 +0x5c fp=0x4000047f90 sp=0x4000047f60 pc=0x43078c
runtime.bgscavenge(0x4000070000)
/usr/local/go/src/runtime/mgcscavenge.go:653 +0x44 fp=0x4000047fb0 sp=0x4000047f90 pc=0x430cd4
runtime.gcenable.gowrap2()
/usr/local/go/src/runtime/mgc.go:204 +0x28 fp=0x4000047fd0 sp=0x4000047fb0 pc=0x4271b8
runtime.goexit({})
/usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x4000047fd0 sp=0x4000047fd0 pc=0x4795b4
created by runtime.gcenable in goroutine 1
/usr/local/go/src/runtime/mgc.go:204 +0xac
goroutine 18 gp=0x4000082700 m=nil [finalizer wait]:
runtime.gopark(0x40000465b8?, 0x4754f8?, 0x8?, 0x0?, 0x573420?)
/usr/local/go/src/runtime/proc.go:402 +0xc8 fp=0x4000046580 sp=0x4000046560 pc=0x447548
runtime.runfinq()
/usr/local/go/src/runtime/mfinal.go:194 +0x108 fp=0x40000467d0 sp=0x4000046580 pc=0x4262e8
runtime.goexit({})
/usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x40000467d0 sp=0x40000467d0 pc=0x4795b4
created by runtime.createfing in goroutine 1
/usr/local/go/src/runtime/mfinal.go:164 +0x80
r0 0x0
r1 0x1
r2 0x6
r3 0xffffbbf15020
r4 0xffffbc822b88
r5 0x1
r6 0x20
r7 0x61641c04ada7d827
r8 0x83
r9 0x203a303032313a63
r10 0x636967614d203d3d
r11 0x67695365726f436b
r12 0x2180
r13 0xa2e64656c696166
r14 0x6e69727453746547
r15 0x7461446f666e4967
r16 0x1
r17 0xffffbc10f654
r18 0x5
r19 0x1
r20 0xffffbbf15020
r21 0x6
r22 0xffffbc54eeb8
r23 0x4b0
r24 0x1ff6efd0
r25 0xffffcd3b9f20
r26 0xffffcd3b7e70
r27 0x1ff6cd60
r28 0x1ff82f30
r29 0xffffcd3b7ba0
lr 0xffffbc1009fc
sp 0xffffcd3b7ba0
pc 0xffffbc100a10
fault 0x0
make: *** [docker-run] Error 2
... and a new sigabrt-demo.zip
I believe I've gotten it resolved. Thanks for the :rubber-duck:.
I used the Dockerfile from https://github.com/docker-library/golang/blob/master/1.22/bookworm/Dockerfile as the basis of my Dockerfile, using the appropriate FROM
to get the golang builder in place.
Oh cool. I'm glad you sorted it. I had a feeling it was related to the base image.
I'm running into a SIGABRT in a dockerized deploy when trying to load a PDF file (that's in memory) into a
MagicWand
via this code. Other image types (JPG, GIF, HEIC) work fine, but any PDF file makes this sad.Details:
gopkg.in/gographics/imagick.v3 v3.7.0
7.1.1-35
I'm sure that I didn't build something correctly for the container, but it's not obvious what that might be.
I'm packaging up a small snippet of code and Dockerfile to help you help me solve this.