Nextcloud , segmentation fault on reinstallation (solved)

Salut,
I encountered this issue today… it took me around two hours for tracking down the issue.
It started first with 502 bad gateway, which was indicated by a stopped php-fpm service, which was aborted by a corrupted ini file. (I did a reinstallation of the application of repairing, because of being short on time)

I did a remove & install session of nextcloud ending up with the “appliation can not be installed” message. Tracing down the error is a “Segmentation fault” of the php executable.
After a bit tracking down, I took a core dump, and did a gdb analysis.

The issue is caused by the php-ImageMagik relation

The segfault happens at the end of the PHP process, while cleaning up things:

The snapshot is from executing php oc manually and forcing just a “file not found”:

 open("/usr/share/doc/imagemagick-6-common/htmlpolicy.xml", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
 open("/home/nextcloud/.config/ImageMagick/policy.xml", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
 open("/home/nextcloud/.magick/policy.xml", O_RDONLY|O_LARGEFILE) = -1 ENOENT (No such file or directory)
 sysinfo({uptime=5407, loads=[27456, 23904, 55264], totalram=2108903424, freeram=1070579712, sharedram=10166272, bufferram=110874624, totalswap=105444
 9664, freeswap=1054449664, procs=184, totalhigh=1339031552, freehigh=505876480, mem_unit=1}) = 0
 ugetrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=1024*1024}) = 0
 brk(0x1f26000)                          = 0x1f26000
 brk(0x1f47000)                          = 0x1f47000
 brk(0x1f68000)                          = 0x1f68000
 mmap2(NULL, 233472, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb2d2c000
 brk(0x1f94000)                          = 0x1f94000
 open("oc", O_RDONLY|O_LARGEFILE)        = -1 ENOENT (No such file or directory)
 fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
 write(1, "Could not open input file: oc\n", 30) = 30
 munmap(0xb2d82000, 98664)               = 0
 munmap(0xb2d65000, 115164)              = 0
 munmap(0xb2df4000, 86232)               = 0
 munmap(0xb2dd5000, 122896)              = 0
 munmap(0xb2d9b000, 234676)              = 0
 munmap(0xb2e0a000, 90328)               = 0
 munmap(0xb2e21000, 86276)               = 0
 munmap(0xb2e37000, 86120)               = 0
 munmap(0xb2e4d000, 77944)               = 0
 munmap(0xb2e61000, 73836)               = 0
 munmap(0xb2e74000, 73832)               = 0
 munmap(0xb2e87000, 73832)               = 0
 munmap(0xb2e9a000, 118948)              = 0
 munmap(0xb2eb8000, 98556)               = 0
 munmap(0xb2ed1000, 73836)               = 0
 munmap(0xb2ee4000, 336140)              = 0
 munmap(0xb2fb8000, 82096)               = 0
 munmap(0xb2f87000, 197396)              = 0
 munmap(0xb2f62000, 147772)              = 0
 munmap(0xb2f37000, 173660)              = 0
 munmap(0xb2fcd000, 82120)               = 0
 munmap(0xb2fe2000, 245096)              = 0
 munmap(0xb301e000, 82152)               = 0
 munmap(0xb3033000, 144548)              = 0
 munmap(0xb308c000, 90252)               = 0
 munmap(0xb3057000, 215572)              = 0
 munmap(0xb3fb4000, 106620)              = 0
 munmap(0xb31bd000, 102520)              = 0
 munmap(0xb31d7000, 90228)               = 0
 munmap(0xb3207000, 362084)              = 0
 munmap(0xb31ee000, 98736)               = 0
 --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0xc600f8b2} ---
 +++ killed by SIGSEGV +++

Here you see the backtrace in the related coredump:

 sudo gdb php /tmp/coredump-php.29502
 GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
 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 "arm-linux-gnueabihf".
 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 php...(no debugging symbols found)...done.
 
 warning: core file may not match specified executable file.
 [New LWP 29502]
 
 warning: Could not load shared library symbols for 6 libraries, e.g. /usr/lib/php/20151012/xml.so.
 Use the "info sharedlibrary" command to see the complete listing.
 Do you need "set solib-search-path" or "set sysroot"?
 [Thread debugging using libthread_db enabled]
 Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
 bt
 Core was generated by `/usr/bin/php oc'.
 Program terminated with signal SIGSEGV, Segmentation fault.
 #0  0xb356c6e4 in LockSemaphoreInfo () from /usr/lib/arm-linux-gnueabihf/libMagickCore-6.Q16.so.3
 (gdb) bt
 #0  0xb356c6e4 in LockSemaphoreInfo () from /usr/lib/arm-linux-gnueabihf/libMagickCore-6.Q16.so.3
 #1  0xb3718d60 in DestroyWandIds () from /usr/lib/arm-linux-gnueabihf/libMagickWand-6.Q16.so.3
 #2  0xb36dd91e in MagickWandTerminus () from /usr/lib/arm-linux-gnueabihf/libMagickWand-6.Q16.so.3
 #3  0xb376c284 in ?? ()
 Backtrace stopped: previous frame identical to this frame (corrupt stack?)
 (gdb) 

This is the yunohost-pastebin link: https://paste.yunohost.org/raw/uhusuzabat

This is the diagnostic json: https://paste.yunohost.org/qogeserago

I’ll do a reinstallation of the library at a next step, but If you have further ideas, helps or advice, I would love to know those :slight_smile:

best regards
Matthias

I reinstalled the following packages, which solved the issue:

========================================
[REINSTALL] imagemagick:armhf 8:6.9.7.4+dfsg-11+deb9u6
[REINSTALL] imagemagick-6-common:armhf 8:6.9.7.4+dfsg-11+deb9u6
[REINSTALL] imagemagick-6.q16:armhf 8:6.9.7.4+dfsg-11+deb9u6
[REINSTALL] libmagickcore-6.q16-3:armhf 8:6.9.7.4+dfsg-11+deb9u6
[REINSTALL] libmagickwand-6.q16-3:armhf 8:6.9.7.4+dfsg-11+deb9u6
[INSTALL] php-imagick:armhf 3.4.3~rc2-2
========================================

After that, I preinstalled the nextcloud-dependencies (to avoid longer retest phases) … well it is working now.

Thanks for your time.
best regards
Matthias