Open
Description
Description
(I'd like to note that while I'm reporting this against PHP 7.4.28, I also saw the problem in PHP 8.0.16)
The following code:
<?php
$connection = ldap_connect("ldaps://ldap.google.com");
$bind_results = ldap_bind($connection, 'AnyUsername','AnyPassword');
Resulted in this output:
PHP Warning: ldap_bind(): Unable to bind to server: Protocol error in /home/ec2-user/testcase.php on line 5
Segmentation fault
But I expected this output instead:
PHP Warning: ldap_bind(): Unable to bind to server: Protocol error in /home/ec2-user/testcase.php on line 5
Removing the ldap_bind()
statement allows the script to run without segfaulting.
When run under GDB, the following backtrace occurs (PHP 7.4):
#0 0x00007fffe8d1b2b0 in ?? ()
#1 0x00007ffff57fb358 in ENGINE_remove (e=0x555555ccb7b0) at eng_list.c:284
#2 0x00007ffff57fb4a5 in engine_list_cleanup () at eng_list.c:94
#3 0x00007ffff57faad6 in engine_cleanup_cb_free (item=0x555555ccbae0) at eng_lib.c:198
#4 0x00007ffff580a507 in sk_pop_free (st=0x555555ccba80, func=0x7ffff57faad0 <engine_cleanup_cb_free>) at stack.c:327
#5 0x00007ffff57fadbc in ENGINE_cleanup () at eng_lib.c:205
#6 0x00007fffec3c627e in ossl_cleanup () at ../../lib/vtls/openssl.c:1228
#7 0x00007fffec3cc087 in Curl_ssl_cleanup () at ../../lib/vtls/vtls.c:254
#8 0x00007fffec37cd42 in curl_global_cleanup () at ../../lib/easy.c:264
#9 0x00007fffec5feab8 in zm_shutdown_curl (type=<optimized out>, module_number=18) at /usr/src/debug/php-7.4.28/ext/curl/interface.c:1439
#10 0x00005555556e54fb in module_destructor (module=module@entry=0x555555c951b0) at /usr/src/debug/php-7.4.28/Zend/zend_API.c:2563
#11 0x00005555556dee8c in module_destructor_zval (zv=<optimized out>) at /usr/src/debug/php-7.4.28/Zend/zend.c:768
#12 0x00005555556f0272 in _zend_hash_del_el_ex (prev=<optimized out>, p=<optimized out>, idx=17, ht=<optimized out>) at /usr/src/debug/php-7.4.28/Zend/zend_hash.c:1305
#13 _zend_hash_del_el (p=0x555555c48140, idx=17, ht=0x555555c1b880 <module_registry>) at /usr/src/debug/php-7.4.28/Zend/zend_hash.c:1328
#14 zend_hash_graceful_reverse_destroy (ht=ht@entry=0x555555c1b880 <module_registry>) at /usr/src/debug/php-7.4.28/Zend/zend_hash.c:1782
#15 0x00005555556e389c in zend_destroy_modules () at /usr/src/debug/php-7.4.28/Zend/zend_API.c:1995
#16 0x00005555556dfda3 in zend_shutdown () at /usr/src/debug/php-7.4.28/Zend/zend.c:1055
#17 0x0000555555682a08 in php_module_shutdown () at /usr/src/debug/php-7.4.28/main/main.c:2534
#18 0x00005555554ec4c8 in main (argc=2, argv=0x555555c320a0) at /usr/src/debug/php-7.4.28/sapi/cli/php_cli.c:1375
Here's the backtrace from PHP 8.0:
#0 0x00007fffef7f62b0 in ?? ()
#1 0x00007ffff55f8358 in ENGINE_remove (e=0x555555c7c990) at eng_list.c:284
#2 0x00007ffff55f84a5 in engine_list_cleanup () at eng_list.c:94
#3 0x00007ffff55f7ad6 in engine_cleanup_cb_free (item=0x555555c7ccc0) at eng_lib.c:198
#4 0x00007ffff5607507 in sk_pop_free (st=0x555555c7cc60, func=0x7ffff55f7ad0 <engine_cleanup_cb_free>) at stack.c:327
#5 0x00007ffff55f7dbc in ENGINE_cleanup () at eng_lib.c:205
#6 0x00007ffff2d9527e in ossl_cleanup () at ../../lib/vtls/openssl.c:1228
#7 0x00007ffff2d9b087 in Curl_ssl_cleanup () at ../../lib/vtls/vtls.c:254
#8 0x00007ffff2d4bd42 in curl_global_cleanup () at ../../lib/easy.c:264
#9 0x00007ffff2fca438 in zm_shutdown_curl (type=<optimized out>, module_number=19) at /usr/src/debug/php-8.0.16/ext/curl/interface.c:1318
#10 0x0000555555702c7b in module_destructor (module=module@entry=0x555555cacc30) at /usr/src/debug/php-8.0.16/Zend/zend_API.c:2631
#11 0x00005555556fc6cc in module_destructor_zval (zv=<optimized out>) at /usr/src/debug/php-8.0.16/Zend/zend.c:782
#12 0x000055555570d942 in _zend_hash_del_el_ex (prev=<optimized out>, p=<optimized out>, idx=18, ht=<optimized out>) at /usr/src/debug/php-8.0.16/Zend/zend_hash.c:1330
#13 _zend_hash_del_el (p=0x555555cce310, idx=18, ht=0x555555c1c000 <module_registry>) at /usr/src/debug/php-8.0.16/Zend/zend_hash.c:1353
#14 zend_hash_graceful_reverse_destroy (ht=ht@entry=0x555555c1c000 <module_registry>) at /usr/src/debug/php-8.0.16/Zend/zend_hash.c:1807
#15 0x00005555557011cc in zend_destroy_modules () at /usr/src/debug/php-8.0.16/Zend/zend_API.c:2008
#16 0x00005555556fd643 in zend_shutdown () at /usr/src/debug/php-8.0.16/Zend/zend.c:1078
#17 0x000055555569e768 in php_module_shutdown () at /usr/src/debug/php-8.0.16/main/main.c:2410
#18 0x00005555554f8228 in main (argc=2, argv=0x555555c330a0) at /usr/src/debug/php-8.0.16/sapi/cli/php_cli.c:1351
AWS Linux 2 Hints (if you need them, of course!)
- To install PHP 7.4 under Amazon Linux 2, try
amazon-linux-extras install php7.4
- You'll also have to install
php-ldap
by doingyum install php-ldap
- You can uninstall one version of php by doing
yum remove php-pdo php-ldap php-debuginfo php-common php-mysqlnd php-fpm php-json php-cli
thenamazon-linux-extras disable php7.4
- then you can enable php8.0. - You'll be prompted by
gdb
to install debuginfo; if you want symbols in your backtraces you'll want to do that.
Please don't hesitate to reach out if there are any further details I can get for you. Thank you!
PHP Version
PHP 7.4.28
Operating System
Amazon Linux 2