php-vips-ext icon indicating copy to clipboard operation
php-vips-ext copied to clipboard

SIGSEGV on OSX

Open dfeyer opened this issue 8 years ago • 12 comments

[02-Dec-2017 00:15:55] WARNING: [pool www] child 1618 exited on signal 11 (SIGSEGV) after 55.787030 seconds from start

Is this a know issue ?

I use vips-8.5.9-Fri Dec 1 23:13:50 CET 2017

vips installed with brew and the php extension compile with pecl

OSX 10.13.1

Tested with PHP 7.1 and 7.2 it's pretty random, sometime everything work and it fast ... and sometimes just crash

Thanks

dfeyer avatar Dec 01 '17 23:12 dfeyer

Oh dear, no, it should be stable. It's being used in production on quite a few sites and no one has reported anything like this.

Could you build with debugging on and get a stack trace on the segv? I could look over your code, if you're able to share it. If you can make a reproducible test-case, that would be best of all, of course.

jcupitt avatar Dec 02 '17 11:12 jcupitt

I try to test the ext with Neos CMS (neos.io). The CMS offer CLI tools to (re)generate thumbnails, and those commands work great, but if the thumbnail are build during a web request, it crash sometimes, I try to debug a bit more to detect where the request crash in the system, if I found nothing, i will try to setup a PHP version with more debuging tools.

dfeyer avatar Dec 04 '17 20:12 dfeyer

So after a bit of debugging the segv happens during the call of vips_foreign_find_load in \Jcupitt\Vips\Image::findLoad.

The value for the filename is /Users/dfeyer/Sites/dev/master-dev.neos-workplace.dev/Data/Temporary/Development/ResourceFiles/10d7e836208ca3c6ede4522fab117b63b6d8260c-1512419089.5465-45446.jpg (test with an without the file extension as the default behaviour of the CMS is to not use file extension for local temporary files, but same result)

→ vipsheader -f vips-loader /Users/dfeyer/Sites/dev/master-dev.neos-workplace.dev/Data/Temporary/Development/ResourceFiles/10d7e836208ca3c6ede4522fab117b63b6d8260c-1512419089.5465-45446.jpg
jpegload

dfeyer avatar Dec 04 '17 20:12 dfeyer

Is it a certain image (or image extension) that random crashes?

Or perhaps a 1x1 GIF image is being processed? If so, then it is fixed with https://github.com/jcupitt/libvips/issues/773.

kleisauke avatar Dec 04 '17 20:12 kleisauke

Interesting! Does that image kill it every time? Could you send the file somehow?

jcupitt avatar Dec 05 '17 08:12 jcupitt

@jcupitt I prepare a small script that process only this image, outside of the CMS, and I publish it if I can reproduce the error

dfeyer avatar Dec 05 '17 09:12 dfeyer

My test project https://github.com/dfeyer/php-vips-ext-test

So the problem seems related to my setup, from the CLI it work nicely, for a web request (Caddy Server + PHP-FPM, configuration included in the repo) it crash

→ php Web/index.php Vips
Driver: Vips
Runtime: 359 ms
Memory usage: 2 MiB (real)
Memory usage: 0.90319061279297 MiB
Generated file size: 61.6318359375 KiB%

→ php Web/index.php Imagick
Driver: Imagick
Runtime: 4100 ms
Memory usage: 2 MiB (real)
Memory usage: 0.74958801269531 MiB
Generated file size: 25.8740234375 KiB%

→ php Web/index.php Gd
Driver: Gd
Runtime: 1137 ms
Memory usage: 306.15234375 MiB (real)
Memory usage: 304.74176025391 MiB
Generated file size: 24.0263671875 KiB%

From a web request:

Works fine: http://localhost:8180/index.php?driver=Gd http://localhost:8180/index.php?driver=Vips

Segv: http://localhost:8180/index.php?driver=Vips

Trying to output a phpinfo, work from the CLI, segv from a web request ...

dfeyer avatar Dec 05 '17 10:12 dfeyer

It seems to work for me from the CLI, but I can't get caddy to cooperate, some error about a bad gateway.

I think your CaddyFile needs to be renamed as Caddyfile, or it'll fail on a case-sensitive system.

$ ~/caddy/caddy
Activating privacy features... done.
NOTICE: Startup directive will be removed in a later version. Please migrate to 'on startup'
NOTICE: Shutdown directive will be removed in a later version. Please migrate to 'on shutdown'
http://*:8180
WARNING: File descriptor limit 1024 is too low for production servers. At least 8192 is recommended. Fix with "ulimit -n 8192".
127.0.0.1 - - [05/Dec/2017:16:31:26 +0000] "GET / HTTP/1.1" 404 38
05/Dec/2017:16:31:27 +0000 [ERROR 502 /index.php] dial tcp 127.0.0.1:9000: getsockopt: connection refused

I'll keep trying.

jcupitt avatar Dec 05 '17 16:12 jcupitt

@jcupitt this command should be fine to launch caddy

caddy --conf CaddyFile --root Web

You need to adapt the path to your PHP FPM binary in the CaddyFile configuration, I use PHP OSX (https://php-osx.liip.ch/), this command work just fine (the wrapper is used to auto select the current PHP version on my machine) :

/usr/local/php5/sbin/php-fpm --fpm-config /usr/local/php5/etc/php-fpm.d/www.conf.default

And BTW thanks a lots for your support 👍

dfeyer avatar Dec 05 '17 17:12 dfeyer

[www]
user = nobody
group = nobody
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

The content of my PHP FPM configuration file

dfeyer avatar Dec 07 '17 09:12 dfeyer

I couldn't reproduce the segv with Caddy + PHP-FPM + PHP 7.2 + libvips 8.5.9 on CentOS 7.4. I was able to successfully create the thumbnail from CLI and web.

BTW, I noticed php5 in your previous message (and in the CaddyFile). Is this on purpose? The binary extension and PHP wrapper only works on PHP 7+.

kleisauke avatar Dec 07 '17 12:12 kleisauke

I noticed php5 in your previous message (and in the CaddyFile). Is this on purpose? The binary extension and PHP wrapper only works on PHP 7+.

It's just a symlink php5 but yes I use PHP 7.0, 7.1 and 7.2 ... and same crash for all the version. So it's something related to OSX or the php build from http://php-osx.liip.ch/ ... I try this morning to have debug build of PHP ... but failed dramaticaly ...

dfeyer avatar Dec 07 '17 15:12 dfeyer