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

SIGSEGV in php-fpm #275

Closed
abalage opened this issue Jul 29, 2016 · 11 comments · Fixed by #646
Closed

SIGSEGV in php-fpm #275

abalage opened this issue Jul 29, 2016 · 11 comments · Fixed by #646
Labels

Comments

@abalage
Copy link

abalage commented Jul 29, 2016

Hello,

I'd like to get some help troubleshooting and fixing this issue I have.
As a base image I am using the '5-fpm-alpine' variant of the images, latest version as of today.
I have added several core and pecl modules with the way as it is described in it's docker hub page.

php-fpm servs - among others - an ownCloud installation which is constantly causing php-fpm to fail with SIGSEGV.

I managed to get core files - however even though I recompiled php with --enable-debug and skipped stripping the symbols from the binaries - but gdb shows nothing useful for me. (I am not a developer)


bash-4.3# gdb -c coredump-php-fpm.11 /usr/local/sbin/php-fpm
GNU gdb (GDB) 7.11
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-alpine-linux-musl".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/.
Find the GDB manual and other documentation resources online at:
http://www.gnu.org/software/gdb/documentation/.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from /usr/local/sbin/php-fpm...done.
[New LWP 11]

warning: Can't read pathname for load map: No error information.
Core was generated by `php-fpm:'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00007ffa3365e80f in free () from /lib/ld-musl-x86_64.so.1

(gdb) bt
#0 0x00007ffa3365e80f in free () from /lib/ld-musl-x86_64.so.1
#1 0x0000000000000020 in ?? ()
#2 0x00007ffa3365f0e8 in memalign () from /lib/ld-musl-x86_64.so.1
#3 0x00005647f095a0a0 in ?? ()
#4 0x00005647f0899680 in ?? ()
#5 0x00005647f0959fc0 in ?? ()
#6 0x0000000000000001 in ?? ()
#7 0x0000000000000000 in ?? ()

(gdb)

dmesg:

[403674.575650] traps: php-fpm[7246] general protection ip:7ffa3365e80f sp:7ffeca2ed950 error:0 in ld-musl-x86_64.so.1[7ffa3363b000+88000]
[403675.578962] traps: php-fpm[7247] general protection ip:7ffa3365e80f sp:7ffeca2ed950 error:0 in ld-musl-x86_64.so.1[7ffa3363b000+88000]


syslog:

Jul 29 11:50:36 localhost docker/balagedocker_php5-fpm_1[15585]: [29-Jul-2016 09:50:36] WARNING: [pool www] child 11 exited on signal 11 (SIGSEGV - core dumped) after 81.363321 seconds from start
Jul 29 11:50:36 localhost docker/balagedocker_php5-fpm_1[15585]: [29-Jul-2016 09:50:36] NOTICE: [pool www] child 27 started
Jul 29 11:50:37 localhost docker/balagedocker_php5-fpm_1[15585]: [29-Jul-2016 09:50:37] WARNING: [pool www] child 12 exited on signal 11 (SIGSEGV - core dumped) after 82.337205 seconds from start
Jul 29 11:50:37 localhost docker/balagedocker_php5-fpm_1[15585]: [29-Jul-2016 09:50:37] NOTICE: [pool www] child 28 started

That's all I got.

I am attaching the Dockerfile I used to build the image. Also some core files if

cores.zip
supervisord.txt
Dockerfile.txt

Host is openSUSE Leap 42.1 x86_64 (kernel 4.1.27-27-default)

Any help is appreciated.

@abalage
Copy link
Author

abalage commented Jul 29, 2016

ps: It would be nice to have to be able to build php/module binaries with debug symbols with the Dockerfiles with only slight modifications. Currently you have to figure it out yourselves.

@abalage
Copy link
Author

abalage commented Aug 9, 2016

I have decided to use the standard packages from alpine - less problematic is getting the debug symbols.
The problem seems to be reproducible even with a simple 'php -i' from command line.

At this point I am not sure this is related to alpine (musl) or php itself (imagick).

Here is the backtrace.

Core was generated by `php -i'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  a_crash () at ./arch/x86_64/atomic_arch.h:108
108     ./arch/x86_64/atomic_arch.h: No such file or directory.
(gdb) bt
#0  a_crash () at ./arch/x86_64/atomic_arch.h:108
#1  free (p=0x562cff699920) at src/malloc/malloc.c:464
#2  0x00007faa3be6c30e in RelinquishMagickMemory () from /usr/lib/libMagickCore-6.Q16.so.2
#3  0x00007faa3bebcfe0 in DeleteMagickThreadKey () from /usr/lib/libMagickCore-6.Q16.so.2
#4  0x00007faa25ec1710 in UnregisterTIFFImage () from /usr/lib/ImageMagick-6.9.4/modules-Q16/coders/tiff.so
#5  0x00007faa3be6d8cd in ?? () from /usr/lib/libMagickCore-6.Q16.so.2
#6  0x00007faa3beaf403 in DestroySplayTree () from /usr/lib/libMagickCore-6.Q16.so.2
#7  0x00007faa3be6e526 in DestroyModuleList () from /usr/lib/libMagickCore-6.Q16.so.2
#8  0x00007faa3be6ee86 in ModuleComponentTerminus () from /usr/lib/libMagickCore-6.Q16.so.2
#9  0x00007faa3be6a25f in MagickCoreTerminus () from /usr/lib/libMagickCore-6.Q16.so.2
#10 0x00007faa3c4480ae in zm_shutdown_imagick () from /usr/lib/php5/modules/imagick.so
#11 0x0000562cfe7bc36c in module_destructor (module=0x562cff370480) at /home/buildozer/aports/main/php5/src/php-5.6.24/Zend/zend_API.c:2376
#12 0x0000562cfe7c0b23 in i_zend_hash_bucket_delete (p=0x562cff3700a0, ht=0x562cfefc4ee0 <module_registry>) at /home/buildozer/aports/main/php5/src/php-5.6.24/Zend/zend_hash.c:182
#13 zend_hash_bucket_delete (ht=ht@entry=0x562cfefc4ee0 <module_registry>, p=0x562cff3700a0) at /home/buildozer/aports/main/php5/src/php-5.6.24/Zend/zend_hash.c:192
#14 0x0000562cfe7c1c54 in zend_hash_graceful_reverse_destroy (ht=0x562cfefc4ee0 <module_registry>) at /home/buildozer/aports/main/php5/src/php-5.6.24/Zend/zend_hash.c:613
#15 0x0000562cfe7bb005 in zend_destroy_modules () at /home/buildozer/aports/main/php5/src/php-5.6.24/Zend/zend_API.c:1894
#16 0x0000562cfe7b5bad in zend_shutdown () at /home/buildozer/aports/main/php5/src/php-5.6.24/Zend/zend.c:836
#17 0x0000562cfe76b0a0 in php_module_shutdown () at /home/buildozer/aports/main/php5/src/php-5.6.24/main/main.c:2477
#18 0x0000562cfe634317 in main (argc=2, argv=0x7faa3e389fa0) at /home/buildozer/aports/main/php5/src/php-5.6.24/sapi/cli/php_cli.c:1393
(gdb)

@abalage
Copy link
Author

abalage commented Aug 9, 2016

I am really just googling Valgrind here. This is all I got.
For me it looks like a problem with imagemagick on Alpine. Not something which ought to be fixed by a Docker 'magic'.

==78== Invalid read of size 8
==78==    at 0x8408FAF: DeleteMagickThreadKey (in /usr/lib/libMagickCore-6.Q16.so.2.0.0)
==78==    by 0x1EB5C70F: UnregisterTIFFImage (in /usr/lib/ImageMagick-6.9.4/modules-Q16/coders/tiff.so)
==78==    by 0x83B98CC: ??? (in /usr/lib/libMagickCore-6.Q16.so.2.0.0)
==78==    by 0x83FB402: DestroySplayTree (in /usr/lib/libMagickCore-6.Q16.so.2.0.0)
==78==    by 0x83BA525: DestroyModuleList (in /usr/lib/libMagickCore-6.Q16.so.2.0.0)
==78==    by 0x83BAE85: ModuleComponentTerminus (in /usr/lib/libMagickCore-6.Q16.so.2.0.0)
==78==    by 0x83B625E: MagickCoreTerminus (in /usr/lib/libMagickCore-6.Q16.so.2.0.0)
==78==    by 0x7DF50AD: zm_shutdown_imagick (in /usr/lib/php5/modules/imagick.so)
==78==    by 0x36636B: module_destructor (zend_API.c:2376)
==78==    by 0x36AB22: i_zend_hash_bucket_delete (zend_hash.c:182)
==78==    by 0x36AB22: zend_hash_bucket_delete (zend_hash.c:192)
==78==    by 0x36BC53: zend_hash_graceful_reverse_destroy (zend_hash.c:613)
==78==    by 0x35FBAC: zend_shutdown (zend.c:836)
==78==  Address 0x1c14c4c0 is 8 bytes after a block of size 8 alloc'd
==78==    at 0x4C91A2C: malloc (vg_replace_malloc.c:299)
==78==    by 0x8408F40: CreateMagickThreadKey (in /usr/lib/libMagickCore-6.Q16.so.2.0.0)
==78==    by 0x1EB5C2E9: RegisterTIFFImage (in /usr/lib/ImageMagick-6.9.4/modules-Q16/coders/tiff.so)
==78==    by 0x83BA4C5: ??? (in /usr/lib/libMagickCore-6.Q16.so.2.0.0)
==78==    by 0x83BAF06: OpenModules (in /usr/lib/libMagickCore-6.Q16.so.2.0.0)
==78==    by 0x83B6691: GetMagickInfo (in /usr/lib/libMagickCore-6.Q16.so.2.0.0)
==78==    by 0x83B6D09: GetMagickList (in /usr/lib/libMagickCore-6.Q16.so.2.0.0)
==78==    by 0x808D44C: MagickQueryFormats (in /usr/lib/libMagickWand-6.Q16.so.2.0.0)
==78==    by 0x7DF4DA5: zm_info_imagick (in /usr/lib/php5/modules/imagick.so)
==78==    by 0x2BA531: _display_module_info_func (info.c:178)
==78==    by 0x36BCB7: zend_hash_apply (zend_hash.c:641)
==78==    by 0x2BAC61: php_print_info (info.c:1073)

@abalage
Copy link
Author

abalage commented Aug 10, 2016

Created a bugreport on Alpine: https://bugs.alpinelinux.org/issues/6021

@SmoshySmosh
Copy link

+1 I am having this same exact issue. I have even tried using graphicsmagick, but after successfully installing gmagick via PECL, I get a SIGSEGV when starting PHP.

Testing with the Debian version now, everything is working great.

@rafi-tvtime
Copy link

+1 I am seeing this issue

[407436.774289] traps: php[16117] general protection ip:7fabf82bf927 sp:7ffc6b07ee50 error:0
[407436.774302]  in ld-musl-x86_64.so.1[7fabf829c000+88000]

@schmunk42
Copy link

schmunk42 commented Aug 22, 2017

Possible workaround: dmstr/docker-php-yii2@58a9b1b

Or you need to wait for PHP (Alpine) 7.2.x, since this is using Alpine-3.6

@tianon
Copy link
Member

tianon commented Dec 22, 2017

So this is solved by PHP 7.2 and/or Alpine 3.6+? (and thus #504)

@schmunk42
Copy link

I think this is solved by Alpine 3.6, probably related to it's C-compiler. CC: @handcode

@kamermans
Copy link

I am also getting ImageMagick segfaults on all Alpine 3.4-based images. The fix is to use a newer version of ImageMagick, but that would require someone to backport the updated 6.9.x branch of ImageMagick to Alpine 3.4 (and apply the security patches that are still relevant).

Alternately, this problem goes away completely if the PHP <= 7.1 docker images are moved to a newer version of Alpine - preferably Alpine 3.6+ since they include ImageMagick 7. I don't know why they aren't built for Alpine 3.6+ today, but I'm happy to help if it's a resource problem.

@axot
Copy link

axot commented Aug 15, 2019

Our php-fpm got SEGV today, is there a simple way to enable debug symbol? Normally -g -O2 flag should not impact performance, should we enable it by default?

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

Successfully merging a pull request may close this issue.

8 participants