MaestroError / php-heic-to-jpg

The easiest way to convert HEIC images to JPEG with PHP and Laravel framework
MIT License
143 stars 20 forks source link

Couldn't convert HEIC to JPG "segmentation violation" #25

Closed zenichanin closed 6 months ago

zenichanin commented 1 year ago

I am getting this error on production server (Linux) but it works on my local Mac. I am using the correct convert vs. convertOnMac methods.

Getting this error:

Couldn't convert HEIC to JPG: 'unexpected fault address 0x7fb05ddac010\nfatal error: fault\n[signal SIGSEGV: segmentation violation code=0x1 addr=0x7fb05ddac010 pc=0x4aeffc]\n\ngoroutine 1 [running]:\nruntime.throw({0x530360?, 0x0?})\n /usr/local/go/src/runtime/panic.go:1047 +0x5d fp=0xc0000f7308 sp=0xc0000f72d8 pc=0x4465fd\nruntime.sigpanic()\n /usr/local/go/src/runtime/signal_unix.go:851 +0x28a fp=0xc0000f7368 sp=0xc0000f7308 pc=0x45ab6a\nimage/jpeg.yCbCrToYCbCr(0xc0000c0100, {0x5eb8e0?, 0x0?}, 0xc000050470, 0xc000050970, 0xc000050570)\n   /usr/local/go/src/image/jpeg/writer.go:461 +0x17c fp=0xc0000f73e8 sp=0xc0000f7368 pc=0x4aeffc\nimage/jpeg.(*encoder).writeSOS(0xc0000c4180, {0x552a78?, 0xc0000c0100?})\n   /usr/local/go/src/image/jpeg/writer.go:547 +0x485 fp=0xc0000f7da0 sp=0xc0000f73e8 pc=0x4af665\nimage/jpeg.Encode({0x552758?, 0xc00009d1a0?}, {0x552a78, 0xc0000c0100}, 0x0)\n   /usr/local/go/src/image/jpeg/writer.go:634 +0x33f fp=0xc0000f7e18 sp=0xc0000f7da0 pc=0x4afadf\nmain.convertHeicToJpg({0x7ffcda40e2af?, 0xc000042718?}, {0x7ffcda40e32e, 0xa0})\n    /go/src/github.com/MaestroError/php-heic-to-jpg/main.go:69 +0x1a6 fp=0xc0000f7ed8 sp=0xc0000f7e18 pc=0x4c0906\nmain.main()\n    /go/src/github.com/MaestroError/php-heic-to-jpg/main.go:22 +0x50 fp=0xc0000f7f80 sp=0xc0000f7ed8 pc=0x4c0570\nruntime.main()\n  /usr/local/go/src/runtime/proc.go:250 +0x207 fp=0xc0000f7fe0 sp=0xc0000f7f80 pc=0x448ee7\nruntime.goexit()\n    /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000f7fe8 sp=0xc0000f7fe0 pc=0x473801\n\ngoroutine 2 [force gc (idle)]:\nruntime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)\n   /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000042fb0 sp=0xc000042f90 pc=0x449316\nruntime.goparkunlock(...)\n    /usr/local/go/src/runtime/proc.go:387\nruntime.forcegchelper()\n    /usr/local/go/src/runtime/proc.go:305 +0xb0 fp=0xc000042fe0 sp=0xc000042fb0 pc=0x449150\nruntime.goexit()\n /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000042fe8 sp=0xc000042fe0 pc=0x473801\ncreated by runtime.init.6\n    /usr/local/go/src/runtime/proc.go:293 +0x25\n\ngoroutine 3 [GC sweep wait]:\nruntime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)\n /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000043780 sp=0xc000043760 pc=0x449316\nruntime.goparkunlock(...)\n    /usr/local/go/src/runtime/proc.go:387\nruntime.bgsweep(0x0?)\n  /usr/local/go/src/runtime/mgcsweep.go:278 +0x8e fp=0xc0000437c8 sp=0xc000043780 pc=0x435f6e\nruntime.gcenable.func1()\n /usr/local/go/src/runtime/mgc.go:178 +0x26 fp=0xc0000437e0 sp=0xc0000437c8 pc=0x42b446\nruntime.goexit()\n  /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000437e8 sp=0xc0000437e0 pc=0x473801\ncreated by runtime.gcenable\n  /usr/local/go/src/runtime/mgc.go:178 +0x6b\n\ngoroutine 4 [GC scavenge wait]:\nruntime.gopark(0xc000028070?, 0x551008?, 0x1?, 0x0?, 0x0?)\n /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000043f70 sp=0xc000043f50 pc=0x449316\nruntime.goparkunlock(...)\n    /usr/local/go/src/runtime/proc.go:387\nruntime.(*scavengerState).park(0x5fc920)\n   /usr/local/go/src/runtime/mgcscavenge.go:400 +0x53 fp=0xc000043fa0 sp=0xc000043f70 pc=0x433eb3\nruntime.bgscavenge(0x0?)\n  /usr/local/go/src/runtime/mgcscavenge.go:628 +0x45 fp=0xc000043fc8 sp=0xc000043fa0 pc=0x434485\nruntime.gcenable.func2()\n  /usr/local/go/src/runtime/mgc.go:179 +0x26 fp=0xc000043fe0 sp=0xc000043fc8 pc=0x42b3e6\nruntime.goexit()\n  /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000043fe8 sp=0xc000043fe0 pc=0x473801\ncreated by runtime.gcenable\n  /usr/local/go/src/runtime/mgc.go:179 +0xaa\n\ngoroutine 18 [finalizer wait]:\nruntime.gopark(0x1a0?, 0x5fcd60?, 0xa0?, 0x61?, 0xc000042770?)\n  /usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000042628 sp=0xc000042608 pc=0x449316\nruntime.runfinq()\n    /usr/local/go/src/runtime/mfinal.go:193 +0x107 fp=0xc0000427e0 sp=0xc000042628 pc=0x42a487\nruntime.goexit()\n  /usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000427e8 sp=0xc0000427e0 pc=0x473801\ncreated by runtime.createfing\n    /usr/local/go/src/runtime/mfinal.go:163 +0x45' | Bin used: 'heicToJpg' HEIC: '{PATH}/storage/app/livewire-tmp/GJaKMOPh3waY8j6ZJJCNGTwixsaPJp-metaMkI4XzU3OTkuaGVpYw==-.heic' Full Command: '{PATH}/vendor/maestroerror/php-heic-to-jpg/src/../bin/heicToJpg "{PATH}/storage/app/livewire-tmp/GJaKMOPh3waY8j6ZJJCNGTwixsaPJp-metaMkI4XzU3OTkuaGVpYw==-.heic" "{PATH}/storage/app/livewire-tmp/GJaKMOPh3waY8j6ZJJCNGTwixsaPJp-metaMkI4XzU3OTkuaGVpYw==-.heic-138155045764e902f20811d2.70833782" 2>&1' Output from heif-converter-image exe:  {"exception":"[object] (RuntimeException(code: 0): Couldn't convert HEIC to JPG: 'unexpected fault address 0x7fb05ddac010\\nfatal error: fault\\n[signal SIGSEGV: segmentation violation code=0x1 addr=0x7fb05ddac010 pc=0x4aeffc]\\n\\ngoroutine 1 [running]:\\nruntime.throw({0x530360?, 0x0?})\\n\t/usr/local/go/src/runtime/panic.go:1047 +0x5d fp=0xc0000f7308 sp=0xc0000f72d8 pc=0x4465fd\\nruntime.sigpanic()\\n\t/usr/local/go/src/runtime/signal_unix.go:851 +0x28a fp=0xc0000f7368 sp=0xc0000f7308 pc=0x45ab6a\\nimage/jpeg.yCbCrToYCbCr(0xc0000c0100, {0x5eb8e0?, 0x0?}, 0xc000050470, 0xc000050970, 0xc000050570)\\n\t/usr/local/go/src/image/jpeg/writer.go:461 +0x17c fp=0xc0000f73e8 sp=0xc0000f7368 pc=0x4aeffc\\nimage/jpeg.(*encoder).writeSOS(0xc0000c4180, {0x552a78?, 0xc0000c0100?})\\n\t/usr/local/go/src/image/jpeg/writer.go:547 +0x485 fp=0xc0000f7da0 sp=0xc0000f73e8 pc=0x4af665\\nimage/jpeg.Encode({0x552758?, 0xc00009d1a0?}, {0x552a78, 0xc0000c0100}, 0x0)\\n\t/usr/local/go/src/image/jpeg/writer.go:634 +0x33f fp=0xc0000f7e18 sp=0xc0000f7da0 pc=0x4afadf\\nmain.convertHeicToJpg({0x7ffcda40e2af?, 0xc000042718?}, {0x7ffcda40e32e, 0xa0})\\n\t/go/src/github.com/MaestroError/php-heic-to-jpg/main.go:69 +0x1a6 fp=0xc0000f7ed8 sp=0xc0000f7e18 pc=0x4c0906\\nmain.main()\\n\t/go/src/github.com/MaestroError/php-heic-to-jpg/main.go:22 +0x50 fp=0xc0000f7f80 sp=0xc0000f7ed8 pc=0x4c0570\\nruntime.main()\\n\t/usr/local/go/src/runtime/proc.go:250 +0x207 fp=0xc0000f7fe0 sp=0xc0000f7f80 pc=0x448ee7\\nruntime.goexit()\\n\t/usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000f7fe8 sp=0xc0000f7fe0 pc=0x473801\\n\\ngoroutine 2 [force gc (idle)]:\\nruntime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)\\n\t/usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000042fb0 sp=0xc000042f90 pc=0x449316\\nruntime.goparkunlock(...)\\n\t/usr/local/go/src/runtime/proc.go:387\\nruntime.forcegchelper()\\n\t/usr/local/go/src/runtime/proc.go:305 +0xb0 fp=0xc000042fe0 sp=0xc000042fb0 pc=0x449150\\nruntime.goexit()\\n\t/usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000042fe8 sp=0xc000042fe0 pc=0x473801\\ncreated by runtime.init.6\\n\t/usr/local/go/src/runtime/proc.go:293 +0x25\\n\\ngoroutine 3 [GC sweep wait]:\\nruntime.gopark(0x0?, 0x0?, 0x0?, 0x0?, 0x0?)\\n\t/usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000043780 sp=0xc000043760 pc=0x449316\\nruntime.goparkunlock(...)\\n\t/usr/local/go/src/runtime/proc.go:387\\nruntime.bgsweep(0x0?)\\n\t/usr/local/go/src/runtime/mgcsweep.go:278 +0x8e fp=0xc0000437c8 sp=0xc000043780 pc=0x435f6e\\nruntime.gcenable.func1()\\n\t/usr/local/go/src/runtime/mgc.go:178 +0x26 fp=0xc0000437e0 sp=0xc0000437c8 pc=0x42b446\\nruntime.goexit()\\n\t/usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000437e8 sp=0xc0000437e0 pc=0x473801\\ncreated by runtime.gcenable\\n\t/usr/local/go/src/runtime/mgc.go:178 +0x6b\\n\\ngoroutine 4 [GC scavenge wait]:\\nruntime.gopark(0xc000028070?, 0x551008?, 0x1?, 0x0?, 0x0?)\\n\t/usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000043f70 sp=0xc000043f50 pc=0x449316\\nruntime.goparkunlock(...)\\n\t/usr/local/go/src/runtime/proc.go:387\\nruntime.(*scavengerState).park(0x5fc920)\\n\t/usr/local/go/src/runtime/mgcscavenge.go:400 +0x53 fp=0xc000043fa0 sp=0xc000043f70 pc=0x433eb3\\nruntime.bgscavenge(0x0?)\\n\t/usr/local/go/src/runtime/mgcscavenge.go:628 +0x45 fp=0xc000043fc8 sp=0xc000043fa0 pc=0x434485\\nruntime.gcenable.func2()\\n\t/usr/local/go/src/runtime/mgc.go:179 +0x26 fp=0xc000043fe0 sp=0xc000043fc8 pc=0x42b3e6\\nruntime.goexit()\\n\t/usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc000043fe8 sp=0xc000043fe0 pc=0x473801\\ncreated by runtime.gcenable\\n\t/usr/local/go/src/runtime/mgc.go:179 +0xaa\\n\\ngoroutine 18 [finalizer wait]:\\nruntime.gopark(0x1a0?, 0x5fcd60?, 0xa0?, 0x61?, 0xc000042770?)\\n\t/usr/local/go/src/runtime/proc.go:381 +0xd6 fp=0xc000042628 sp=0xc000042608 pc=0x449316\\nruntime.runfinq()\\n\t/usr/local/go/src/runtime/mfinal.go:193 +0x107 fp=0xc0000427e0 sp=0xc000042628 pc=0x42a487\\nruntime.goexit()\\n\t/usr/local/go/src/runtime/asm_amd64.s:1598 +0x1 fp=0xc0000427e8 sp=0xc0000427e0 pc=0x473801\\ncreated by runtime.createfing\\n\t/usr/local/go/src/runtime/mfinal.go:163 +0x45' | Bin used: 'heicToJpg' HEIC: '{PATH}/storage/app/livewire-tmp/GJaKMOPh3waY8j6ZJJCNGTwixsaPJp-metaMkI4XzU3OTkuaGVpYw==-.heic' Full Command: '{PATH}/vendor/maestroerror/php-heic-to-jpg/src/../bin/heicToJpg \"{PATH}/storage/app/livewire-tmp/GJaKMOPh3waY8j6ZJJCNGTwixsaPJp-metaMkI4XzU3OTkuaGVpYw==-.heic\" \"{PATH}/storage/app/livewire-tmp/GJaKMOPh3waY8j6ZJJCNGTwixsaPJp-metaMkI4XzU3OTkuaGVpYw==-.heic-138155045764e902f20811d2.70833782\" 2>&1' Output from heif-converter-image exe:  at `{PATH}/vendor/maestroerror/php-heic-to-jpg/src/HeicToJpg.php:204

Server info: Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-1028-aws x86_64)

MaestroError commented 1 year ago

Hey @zenichanin! Sorry for the late response 👍 If you haven't already solved the issue, it can be due to error in image path, check this out, it is your full command executed by package under the hood: {PATH}/vendor/maestroerror/php-heic-to-jpg/src/../bin/heicToJpg "{PATH}/storage/app/livewire-tmp/GJaKMOPh3waY8j6ZJJCNGTwixsaPJp-metaMkI4XzU3OTkuaGVpYw==-.heic" "{PATH}/storage/app/livewire-tmp/GJaKMOPh3waY8j6ZJJCNGTwixsaPJp-metaMkI4XzU3OTkuaGVpYw==-.heic-138155045764e902f20811d2.70833782" 2>&1

There are strange {PATH} strings in your images locations, I assume that it should be replaced by something, but it isn't 👍

zenichanin commented 1 year ago

Hey @MaestroError I just changed the system path to {PATH} that is not actually in the command or the error.

The thing is it works perfectly fine on our local Mac and Windows, yet it returns that on the Ubuntu production server.

The image path we pass is the full system path starting from /home/user/etc...

zyood01 commented 1 year ago

i face the same issues in ec2 yum server.

locale in ubuntu os working good when I add :

base_path() . "/vendor/bin/heif-converter-linux".

but in the server not working.

any suggestions, please .

t-k-c commented 10 months ago

I have this same issue on a docker container! I even verify if the file exists and it does exist.

thomas-kurz commented 8 months ago

Same Issue here. Any suggested solutions?

MaestroError commented 8 months ago

Hi, guys! I tried several times but couldn't reproduce an issue. So, the only things I can suggest for now:

Any contributions are welcome! ❤️

MaestroError commented 8 months ago

Also, you can consider using JS package, if applicable: heic2any

MaestroError commented 8 months ago

Please, comment here if any of suggested packages helped you ❤️

salmanahmad10 commented 8 months ago

getting the same issue [2024-02-13 11:40:22] local.DEBUG: RuntimeException: Couldn't convert HEIC to JPG: '2024/02/13 07:40:22 heif: no EXIF found\nunexpected fault address 0xffff7deaa010\nfatal error: fault\n[signal SIGSEGV: segmentation violation code=0x1 addr=0xffff7deaa010 pc=0x4b5f5c]\n\ngoroutine 1 [running]:\nruntime.throw(0x545dad, 0x5)\n /usr/local/go/src/runtime/panic.go:774 +0x54 fp=0x40000db260 sp=0x40000db230 pc=0x43ceb4\nruntime.sigpanic()\n /usr/local/go/src/runtime/signal_unix.go:401 +0x3cc fp=0x40000db290 sp=0x40000db260 pc=0x45023c\nimage/jpeg.yCbCrToYCbCr(0x40000c4100, 0x0, 0x0, 0x40000db3c0, 0x40000db8c0, 0x40000db4c0)\n /usr/local/go/src/image/jpeg/writer.go:461 +0x10c fp=0x40000db320 sp=0x40000db2a0 pc=0x4b5f5c\nimage/jpeg.(*encoder).writeSOS(0x400014a000, 0x565fc0, 0x40000c4100)\n /usr/local/go/src/image/jpeg/writer.go:547 +0x2d8 fp=0x40000dbce0 sp=0x40000db320 pc=0x4b6448\nimage/jpeg.Encode(0x565160, 0x4000146000, 0x565fc0, 0x40000c4100, 0x0, 0x565160, 0x4000146000)\n /usr/local/go/src/image/jpeg/writer.go:634 +0x230 fp=0x40000dbd60 sp=0x40000dbce0 pc=0x4b6920\nmain.convertHeicToJpg(0xfffff4aaa9e5, 0x26, 0xfffff4aaaa0c, 0x47, 0x0, 0x0)\n /go/src/github.com/MaestroError/php-heic-to-jpg/main.go:69 +0x1ec fp=0x40000dbe90 sp=0x40000dbd60 pc=0x4c756c\nmain.main()\n /go/src/github.com/MaestroError/php-heic-to-jpg/main.go:22 +0x60 fp=0x40000dbf50 sp=0x40000dbe90 pc=0x4c7160\nruntime.main()\n /usr/local/go/src/runtime/proc.go:203 +0x23c fp=0x40000dbfd0 sp=0x40000dbf50 pc=0x43e78c\nruntime.goexit()\n /usr/local/go/src/runtime/asm_arm64.s:1128 +0x4 fp=0x40000dbfd0 sp=0x40000dbfd0 pc=0x466394' | Bin used: 'php-heic-to-jpg-linux-arm64' HEIC: 'HTTP-118050687365cb1ce535dd31.13532322' Full Command: '/var/www/html/vendor/maestroerror/php-heic-to-jpg/src/../bin/php-heic-to-jpg-linux-arm64 "HTTP-118050687365cb1ce535dd31.13532322" "HTTP-118050687365cb1ce535dd31.13532322-64072229565cb1ce6baeb09.47286249" 2>&1' Output from heif-converter-image exe: in /var/www/html/vendor/maestroerror/php-heic-to-jpg/src/HeicToJpg.php:208