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

PHP 7.3.17 segmentation fault #70

Closed
nicolacontu opened this issue Jun 9, 2020 · 14 comments · Fixed by #76
Closed

PHP 7.3.17 segmentation fault #70

nicolacontu opened this issue Jun 9, 2020 · 14 comments · Fixed by #76

Comments

@nicolacontu
Copy link

Hello,
it seems this does not support 7.3.17

I am still using it on PHP 7.2.27 but with 7.3 I get segmentation fault :

[20200609 11:47 1011 [email protected]:~/downloads/memcache-4.0.5.2]# TEST_PHP_EXECUTABLE=/usr/local/php/bin/php php -dextension=memcache.so run-tests.php -d extension=memcache.so

=====================================================================
PHP : /usr/local/php/bin/php
PHP_SAPI : cli
PHP_VERSION : 7.3.17
ZEND_VERSION: 3.3.17
PHP_OS : Linux - Linux cmd-preprod1.nyh.gt-t.net 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64
INI actual : /usr/local/php7.3.17/etc/php.ini
More .INIs :

PHP : /usr/local/php7.3.17/bin/phpdbg
PHP_SAPI : phpdbg
PHP_VERSION : 7.3.17
ZEND_VERSION: 3.3.17
PHP_OS : Linux - Linux cmd-preprod1.nyh.gt-t.net 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64
INI actual : /usr/local/php7.3.17/etc/php.ini
More .INIs :

CWD : /root/downloads/memcache-4.0.5.2
Extra dirs :
VALGRIND : Not used

TIME START 2020-06-09 11:47:28

PASS memcache_set() function [tests/001.phpt]
PASS memcache_get() function [tests/002.phpt]
PASS memcache_set()/memcache_get() using compression [tests/003.phpt]
PASS memcache_add() & memcache_replace() [tests/004.phpt]
PASS strange keys [tests/005.phpt]
PASS memcache_increment() & memcache_decrement() [tests/006.phpt]
PASS memcache_get_version() & memcache_get_stats() [tests/007.phpt]
PASS memcache_delete() [tests/008.phpt]
FAIL memcache->set() method [tests/009.phpt]
PASS memcache->get() function [tests/010.phpt]
PASS memcache->set()/memcache->get() using compression [tests/011.phpt]
PASS memcache_add() & memcache_replace() [tests/012.phpt]
PASS memcache->set() & memcache->get() with strange keys [tests/013.phpt]
PASS memcache->increment() & memcache->decrement() [tests/014.phpt]
PASS memcache->getVersion() & memcache->getStats() [tests/015.phpt]
PASS memcache->delete() [tests/016.phpt]
PASS Memcache class should be inheritable [tests/017.phpt]
PASS memcache_set() & memcache_add() [tests/018.phpt]
FAIL memcache->addServer() [tests/019.phpt]
PASS memcache_add_server() [tests/019a.phpt]
FAIL memcache->set()/memcache->get() with multiple keys and load balancing [tests/020.phpt]
PASS memcache->set()/memcache->get() with failover [tests/021.phpt]
FAIL memcache->getExtendedStats() [tests/022.phpt]
FAIL memcache_get_extended_stats() [tests/022a.phpt]
FAIL memcache->delete() with load balancing [tests/023.phpt]
PASS memcache->close(), memcache->get() [tests/024.phpt]
PASS memcache_close(), memcache_get() [tests/024a.phpt]
FAIL memcache->increment() with load balancing [tests/025.phpt]
FAIL memcache->delete() with load balancing [tests/026.phpt]
PASS memcache->setCompressThreshold() [tests/027.phpt]
PASS memcache_set_compress_threshold() [tests/027a.phpt]
PASS memcache->addServer() and memcache->close() [tests/028.phpt]
PASS ini_set("memcache.allow_failover") [tests/029.phpt]
PASS ini_set("memcache.chunk_size") [tests/030.phpt]
FAIL memcache->addServer() adding server in failed mode [tests/031.phpt]
FAIL memcache->getServerStatus(), memcache->setServerParams() [tests/032.phpt]
PASS memcache->addServer() with server failure callback [tests/033.phpt]
PASS memcache->getStats() with arguments [tests/034.phpt]
FAIL memcache::connect() with unix domain socket [tests/035.phpt]
PASS ini_set('session.save_handler') [tests/036.phpt]
PASS ini_set('session.save_path') [tests/036b.phpt]
PASS ini_set('memcache.hash_strategy') [tests/037.phpt]
SKIP memcache->get() over UDP [tests/038.phpt] reason: known bug
SKIP memcache->get() over multi-datagram UDP [tests/039.phpt] reason: UDP is not enabled in connect.inc
FAIL memcache->increment()/decrement() with multiple keys [tests/040.phpt]
FAIL memcache->delete() with multiple keys [tests/041.phpt]
FAIL memcache->set() with multiple values [tests/042.phpt]
FAIL ini_set('memcache.redundancy') [tests/043.phpt]
SKIP ini_set('memcache.session_redundancy') [tests/044.phpt]
PASS Nested get's in __wakeup() [tests/045.phpt]
FAIL hash strategies and functions [tests/046.phpt]
PASS memcache->get() with flags [tests/047.phpt]
PASS memcache->get(), set() with CAS [tests/048.phpt]
PASS memcache->append(), memcache->prepend() [tests/049.phpt]
PASS failure callback throws exception [tests/050.phpt]
PASS memcache->set() with duplicate keys [tests/051.phpt]
PASS memcache->connect() and memcache->close() in loop [tests/052.phpt]
FAIL ini_set('session.save_handler') with unix domain socket [tests/053.phpt]
PASS memcache->set() with value larger than MTU [tests/054.phpt]
PASS memcache->set()/get() datatype preservation [tests/055.phpt]
PASS memcache->addServer() with microsecond timeout [tests/056.phpt]
PASS session locking [tests/057.phpt]
PASS memcache->findServer() [tests/058.phpt]
PASS memcache->flush() [tests/100.phpt]
PASS memcache_flush() [tests/100a.phpt]
PASS memcache->flush() with time in future [tests/100b.phpt]
SKIP memcache multi host save path function [tests/bug73539.phpt] reason: not relevant for php 7.1+
PASS session_regenerate_id() should not cause fatal error [tests/githubbug13.phpt]
PASS PECL bug #11221 (Double free when returning cached object with __sleep) [tests/pecl11221.phpt]
PASS PECL bug #16442 (memcache_set fail with integer value) [tests/pecl16442.phpt]
PASS PECL bug #16536 (Weight of 0 causes SegFault on memcache_add_server) [tests/pecl16536.phpt]
PASS PECL bug #17518 (Strange behavior in increment on non integer and after) [tests/pecl17518.phpt]
PASS PECL bug #17566 (3.0.4 cache delete bug) [tests/pecl17566.phpt]
PASS PECL bug #63142 (memcache 3.0.7 segfaults with object (un)serialization) [tests/pecl63142.phpt]

TIME END 2020-06-09 11:47:38

=====================================================================
TEST RESULT SUMMARY

Exts skipped : 0
Exts tested : 61

Number of tests : 74 70
Tests skipped : 4 ( 5.4%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 17 ( 23.0%) ( 24.3%)
Expected fail : 0 ( 0.0%) ( 0.0%)
Tests passed : 53 ( 71.6%) ( 75.7%)

Time taken : 10 seconds

=====================================================================
FAILED TEST SUMMARY

memcache->set() method [tests/009.phpt]
memcache->addServer() [tests/019.phpt]
memcache->set()/memcache->get() with multiple keys and load balancing [tests/020.phpt]
memcache->getExtendedStats() [tests/022.phpt]
memcache_get_extended_stats() [tests/022a.phpt]
memcache->delete() with load balancing [tests/023.phpt]
memcache->increment() with load balancing [tests/025.phpt]
memcache->delete() with load balancing [tests/026.phpt]
memcache->addServer() adding server in failed mode [tests/031.phpt]
memcache->getServerStatus(), memcache->setServerParams() [tests/032.phpt]
memcache::connect() with unix domain socket [tests/035.phpt]
memcache->increment()/decrement() with multiple keys [tests/040.phpt]
memcache->delete() with multiple keys [tests/041.phpt]
memcache->set() with multiple values [tests/042.phpt]
ini_set('memcache.redundancy') [tests/043.phpt]
hash strategies and functions [tests/046.phpt]
ini_set('session.save_handler') with unix domain socket [tests/053.phpt]

Here are the tests I run.

Can you please check and let me know?

Thanks

@TysonAndre
Copy link
Contributor

TysonAndre commented Jun 9, 2020

Hi - Not a maintainer, but at a glance, it looks like you need to start memcached on port 11212 as well to run the tests that failed. You probably already have one running on port 11211. See https://github.com/websupport-sk/pecl-memcache/blob/NON_BLOCKING_IO_php7/tests/connect.inc#L17-L18

The test failures are probably unrelated to the segmentation fault you're seeing in your configuration. Are you able to provide stack traces or core dumps for the segmentation fault?

You can run make test TESTS=--show-diff to show the test output.

@nicolacontu
Copy link
Author

nicolacontu commented Jun 9, 2020 via email

@TysonAndre
Copy link
Contributor

---------------------------------------------------------------------
memcache::connect() with unix domain socket [tests/035.phpt]
ini_set('session.save_handler') with unix domain socket [tests/053.phpt]

$domainsocket = 'unix:///var/run/memcached/memcached.sock';

The tests are unrelated to the segfault. You need to mkdir -p /var/run/memcached and memcached -s /var/run/memcached/memcached.sock to run those tests.

t might be useful if the test scripts skip if those memcached servers don't exist, but that's up to the maintainers to decide

@nicolacontu

  1. How was PHP being run when it segfaulted? If it was a web server, what type of webserver (apache? php-fpm? other?)
  2. What memcached server/proxy software (and version) were you connecting to?
  3. Can you provide a core dump (e.g. https://bugs.php.net/bugs-generating-backtrace.php - instructions may vary based on server software and os versions)
  4. How is "memcache" being used? Is this pecl module used for sessions through the session handler?

@nicolacontu
Copy link
Author

nicolacontu commented Jun 10, 2020 via email

@TysonAndre
Copy link
Contributor

  1. It would help if you attach the output of (gdb) bt to print the backtrace of that. To get a useful backtrace, installing debugging info would help get line numbers and file names, but that doesn't seem to include php, so it probably wouldn't help much.

    Missing separate debuginfos, use: debuginfo-install aspell-0.60.6.1-9.el7.x86_64 audit-libs-2.8.5-4.el7.x86_64 bzip2-libs-1.0.6-13.el7.x86_64 cairo-1.15.12-4.el7.x86_64 cyrus-sasl-lib-2.1.26-23.el7.x86_64 elfutils-libelf-0.176-4.el7.x86_64 elfutils-libs-0.176-4.el7.x86_64 expat-2.1.0-11.el7.x86_64 fontconfig-2.13.0-4.3.el7.x86_64 freetype-2.8-14.el7.x86_64 fribidi-1.0.2-1.el7_7.1.x86_64 gdbm-1.10-8.el7.x86_64 glib2-2.56.1-5.el7.x86_64 glibc-2.17-307.el7.1.x86_64 gmp-6.0.0-15.el7.x86_64 graphite2-1.3.10-1.el7_3.x86_64 harfbuzz-1.7.5-2.el7.x86_64 keyutils-libs-1.5.8-3.el7.x86_64 krb5-libs-1.15.1-46.el7.x86_64 libX11-1.6.7-2.el7.x86_64 libXau-1.0.8-2.1.el7.x86_64 libXext-1.3.3-3.el7.x86_64 libXrender-0.9.10-1.el7.x86_64 libaio-0.3.109-13.el7.x86_64 libattr-2.4.46-13.el7.x86_64 libc-client-2007f-16.el7.x86_64 libcap-2.22-11.el7.x86_64 libcap-ng-0.7.5-4.el7.x86_64 libcom_err-1.42.9-17.el7.x86_64 libcurl-7.65.3-4.0.cf.rhel7.x86_64 libffi-3.0.13-19.el7.x86_64 libgcc-4.8.5-39.el7.x86_64 libgcrypt-1.5.3-14.el7.x86_64 libglvnd-1.0.1-0.8.git5baa1e5.el7.x86_64 libglvnd-egl-1.0.1-0.8.git5baa1e5.el7.x86_64 libglvnd-glx-1.0.1-0.8.git5baa1e5.el7.x86_64 libgpg-error-1.12-3.el7.x86_64 libicu-50.2-4.el7_7.x86_64 libjpeg-turbo-1.2.90-8.el7.x86_64 libnghttp2-1.31.1-2.el7.x86_64 libpng-1.5.13-7.el7_2.x86_64 libpsl-0.7.0-1.el7.x86_64 libselinux-2.5-15.el7.x86_64 libssh2-1.9.0-2.0.cf.rhel7.x86_64 libstdc++-4.8.5-39.el7.x86_64 libthai-0.1.14-9.el7.x86_64 libtool-ltdl-2.4.2-22.el7_3.x86_64 libuuid-2.23.2-63.el7.x86_64 libwbclient-4.10.4-11.el7_8.x86_64 libxcb-1.13-1.el7.x86_64 libxml2-2.9.1-6.el7.4.x86_64 libxslt-1.1.28-5.el7.x86_64 nspr-4.21.0-1.el7.x86_64 nss-3.44.0-7.el7_7.x86_64 nss-softokn-freebl-3.44.0-8.el7_7.x86_64 nss-util-3.44.0-4.el7_7.x86_64 openldap-2.4.44-21.el7_6.x86_64 openssl-libs-1.0.2k-19.el7.x86_64 pam-1.1.8-23.el7.x86_64 pango-1.42.4-4.el7_7.x86_64 pcre-8.32-17.el7.x86_64 pixman-0.34.0-1.el7.x86_64 rrdtool-1.4.8-9.el7.x86_64 samba-client-libs-4.10.4-11.el7_8.x86_64 samba-winbind-modules-4.10.4-11.el7_8.x86_64 systemd-libs-219-73.el7_8.5.x86_64 unixODBC-2.3.1-14.el7.x86_64 xz-libs-5.2.2-1.el7.x86_64 zlib-1.2.7-18.el7.x86_64

  2. What mpm module are you using? At a glance at the gdb output, I'm guessing you're using a threaded one (I'm not very familiar with apache's internals). Which mpm module are you using? Does the issue go away if you switch to prefork? (Knowing if an issue is limited to threaded apache will help maintainers diagnose/fix this)

For example, my centos config in /etc/httpd/conf.modules.d/00-mpm.conf is using mpm_prefork_module. It'll probably be in a folder starting with /etc/httpd or /etc/apache, which varies based on OS (grep -Ri for mpm)

# Select the MPM module which should be used by uncommenting exactly
# one of the following LoadModule lines:

# prefork MPM: Implements a non-threaded, pre-forking web server
# See: http://httpd.apache.org/docs/2.4/mod/prefork.html
LoadModule mpm_prefork_module modules/mod_mpm_prefork.so

# worker MPM: Multi-Processing Module implementing a hybrid
# multi-threaded multi-process web server
# See: http://httpd.apache.org/docs/2.4/mod/worker.html
#
#LoadModule mpm_worker_module modules/mod_mpm_worker.so

# event MPM: A variant of the worker MPM with the goal of consuming
# threads only for connections with active processing
# See: http://httpd.apache.org/docs/2.4/mod/event.html
#
#LoadModule mpm_event_module modules/mod_mpm_event.so

@TysonAndre
Copy link
Contributor

I'd have thought it might be due to servers getting shared somehow, but I'm unfamiliar with the codebase. The memcache server string (tcp://) doesn't have persistent (which is correct if threads are used), and it looks like memcache shouldn't be sharing servers/pool structs at a glance.

@nicolacontu
Copy link
Author

nicolacontu commented Jun 10, 2020 via email

@nicolacontu
Copy link
Author

nicolacontu commented Jun 10, 2020 via email

@TysonAndre
Copy link
Contributor

What's the full output of php --version (including NTS/ZTS)? If it's an NTS build, I don't think this module would work with mpm "Threaded: yes" - you'd need to switch to zts (a php build that supports running with threads) or to mpm prefork (to stop using threads).

The MEMCACHE_G(session_key_prefix) would be using a thread-local in ZTS but what seems like a static variable in NTS

#ifdef ZTS
#define MEMCACHE_G(v) TSRMG(memcache_globals_id, zend_memcache_globals *, v)
#else
#define MEMCACHE_G(v) (memcache_globals.v)
#endif

@TysonAndre
Copy link
Contributor

  1. apache is compiled and it is uses the default one. it should be prefork.
    ...
    I was able to take a look at the MPM module :

MPM Name: event

If you refer to https://httpd.apache.org/docs/2.4/mod/#core , the "event" mpm is a variation of the "worker" mpm, both of which are threaded. That is a different mpm from the non-threaded "prefork" mpm. (Not 100% sure if that is what you meant by that)

@nicolacontu
Copy link
Author

nicolacontu commented Jun 10, 2020 via email

@TysonAndre
Copy link
Contributor

Okay, not completely sure what's causing the segfault, then

  • Could be the string that MEMCACHE_G(session_key_prefix) was initially valid, but no longer became valid
  • Maybe the order in which extensions are loaded matters? Does it help to put extension=memcache.so before extension=session.so (or if they're in php.d/, change the file order?) (did php_request_startup initialize session before memcache got initialized - if so, that would explain why session_key_prefix pointed to invalid memory)

@nicolacontu
Copy link
Author

nicolacontu commented Jun 11, 2020 via email

@thesource93 thesource93 linked a pull request Oct 16, 2020 that will close this issue
@thesource93
Copy link
Contributor

this should be fixed in recent version, closing

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

Successfully merging a pull request may close this issue.

3 participants