From: arekm at maven dot pl Operating system: PHP version: 5.3.19 Package: GNU MP related Bug Type: Bug Bug description:Not really sane memory management initialization
Description: ------------ php gmp module uses: mp_set_memory_functions(gmp_emalloc, gmp_erealloc, gmp_efree); to switch to Zend memory management functions. The problem is that there are other modules that use gmp. One is php-curl in case when curl uses gnutls for SSL connections (gnutls >= 3.1.1). gnutls also uses gmp. The problem happens when curl first uses gmp, gmp allocates some things (using generic memory management functions) and then php-gmp module changes memory management functions to own (Zend) one. Then memory allocated by generic functions is going to be reallocated/freed using Zend functions which causes segfault. Probably the solution would be to immediately set mp_set_memory_functions to Zend functions, before any other module has a chance to initialize gmp. More: http://lists.gnu.org/archive/html/help-gnutls/2012-11/msg00050.html http://lists.gnu.org/archive/html/help-gnutls/2012-11/msg00049.html Test script: --------------- - build php with curl and gmp - libcurl library needs to be built with gnutls >= 3.1.1 - run php cli - press ctrl+D => result = segfault Expected result: ---------------- No segfault. Actual result: -------------- Segfault. Program received signal SIGSEGV, Segmentation fault. 0x00007fffea23ef20 in ?? () (gdb) bt #0 0x00007fffea23ef20 in ?? () #1 0x00007fffeb445d3b in mp_clear_multi (address@hidden) at multi.c:38 #2 0x00007fffeb4472ca in ecc_del_point (p=0xc63ed0) at ecc_points.c:62 #3 0x00007fffeb446972 in _ecc_wmnaf_cache_entry_free (p=<optimized out>) at ecc_mulmod_cached.c:54 #4 ecc_wmnaf_cache_free () at ecc_mulmod_cached.c:68 #5 0x00007fffeb445685 in gnutls_crypto_deinit () at init.c:44 #6 0x00007fffeb3adb71 in gnutls_global_deinit () at gnutls_global.c:305 #7 0x00007fffee0c9a79 in Curl_gtls_cleanup () at gtls.c:182 #8 0x00007fffee0ca189 in Curl_ssl_cleanup () at sslgen.c:193 #9 0x00007fffee0bbbf5 in curl_global_cleanup () at easy.c:325 #10 0x00007fffee6f9bf8 in zm_shutdown_curl () from /usr/lib64/php/curl.so #11 0x00007ffff7a96105 in module_destructor () from /usr/lib64/libphp_common-5.3.18.so #12 0x00007ffff7a9b4ae in ?? () from /usr/lib64/libphp_common-5.3.18.so #13 0x00007ffff7a9cd08 in zend_hash_graceful_reverse_destroy () from /usr/lib64/libphp_common-5.3.18.so #14 0x00007ffff7a8f175 in zend_shutdown () from /usr/lib64/libphp_common-5.3.18.so #15 0x00007ffff7a3e01b in php_module_shutdown () from /usr/lib64/libphp_common-5.3.18.so #16 0x0000000000403406 in main () (gdb) -- Edit bug report at https://bugs.php.net/bug.php?id=63595&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=63595&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=63595&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=63595&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=63595&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=63595&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=63595&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=63595&r=needscript Try newer version: https://bugs.php.net/fix.php?id=63595&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=63595&r=support Expected behavior: https://bugs.php.net/fix.php?id=63595&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=63595&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=63595&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=63595&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=63595&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=63595&r=dst IIS Stability: https://bugs.php.net/fix.php?id=63595&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=63595&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=63595&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=63595&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=63595&r=mysqlcfg