|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-09-14 01:29 UTC] madcoder at gmail dot com
Description:
------------
I'm getting a segmentation fault when calling ldap_get_entries() after an ldap search. I get no errors after any of the function calls prior to ldap_get_entries() (as suggested by ldap_errno() == 0).
Running a similar ldapsearch command line query returns results as expected.
A similar configuration on another linux installation of the same version works with no problems. The major difference between those two servers is the CPU (the working one is an Intel P4, the one that is segfaulting is an AMD 64-bit Athlon XP)
Reproduce code:
---------------
<?php
$_SERVER['ldap'] = ldap_connect("ldap://server.domain");
ldap_set_option($_SERVER['ldap'], LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_set_option($_SERVER['ldap'], LDAP_OPT_REFERRALS, 0);
ldap_start_tls($_SERVER['ldap']);
ldap_bind($_SERVER['ldap'], 'user@domain', 'password');
$r = ldap_search($_SERVER['ldap'], 'dc=fq,dc=domain,dc=name', '(sAMAccountName=someUser)');
echo "done searching\n";
$info = ldap_get_entries($_SERVER['ldap'], $r);
echo "done fetching\n";
?>
Expected result:
----------------
"done fetching\n" should be printed, and $info should contain an array of entries returned from the LDAP server.
Actual result:
--------------
# php -e test.php
done searching
Segmentation fault (core dumped)
----------
# gdb php core
GNU gdb 6.4
(gdb) bt
#0 0x00002aaaac8cbf4b in ?? ()
#1 0xa6e95d9926b7ed00 in ?? ()
#2 0x0000555555dbe260 in ?? ()
#3 0x0000555555de16c0 in ?? ()
#4 0x00005555556a92b5 in ?? ()
#5 0x000000000000000f in ?? ()
#6 0x0000000000000001 in ?? ()
#7 0x000000000000000f in ?? ()
#8 0x00002aaaaea76cf0 in ?? ()
#9 0x0000000000000003 in ?? ()
#10 0x0000000000000000 in ?? ()
(I realize this backtrace is not helpful... I've tried re-emerging the php ebuild several times with the debug USE flag enabled, and it seems all the debug info is still being stripped from the binaries. I will try compiling from source with the appropriate options and reply with a more useful backtrace)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 25 18:00:01 2025 UTC |
Sorry for the delay (I had to fix an error with gdb not generating backtraces on AMD64...) Here's the backtrace: ----- (gdb) run Starting program: /usr/bin/php -e test.php [Thread debugging using libthread_db enabled] [New Thread 47773184727840 (LWP 28424)] done searching Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 47773184727840 (LWP 28424)] 0x00002b730d78de44 in ldap_count_values (vals=0x55e99220) at getvalues.c:153 153 getvalues.c: No such file or directory. in getvalues.c ----- (gdb) bt #0 0x00002b730d78de44 in ldap_count_values (vals=0x55e99220) at getvalues.c:153 #1 0x00005555556a25c0 in zif_ldap_get_entries (ht=1441370656, return_value=0x555555e987a8, return_value_ptr=0x0, this_ptr=0x0, return_value_used=1438266616, tsrm_ls=0x555555e9cc60) at /var/tmp/portage/php-5.1.6-r4/work/php-5.1.6/ext/ldap/ldap.c:1068 #2 0x0000555555890d35 in zend_do_fcall_common_helper_SPEC (execute_data=0x7fff9f13efb0, tsrm_ls=0x555555ba4450) at zend_vm_execute.h:200 #3 0x0000555555899c6a in ZEND_DO_FCALL_SPEC_CONST_HANDLER (execute_data=0x7fff9f13efb0, tsrm_ls=0x555555ba4450) at zend_vm_execute.h:1640 #4 0x000055555589039b in execute (op_array=0x555555e96ad8, tsrm_ls=0x555555ba4450) at zend_vm_execute.h:92 #5 0x0000555555868a42 in zend_execute_scripts (type=8, tsrm_ls=0x555555ba4450, retval=0x0, file_count=3) at /var/tmp/portage/php-5.1.6-r4/work/php-5.1.6/Zend/zend.c:1109 #6 0x000055555580f825 in php_execute_script (primary_file=0x7fff9f1415d0, tsrm_ls=0x555555ba4450) at /var/tmp/portage/php-5.1.6-r4/work/php-5.1.6/main/main.c:1737 #7 0x0000555555939484 in main (argc=3, argv=0x7fff9f141888) at /var/tmp/portage/php-5.1.6-r4/work/php-5.1.6/sapi/cli/php_cli.c:1093 ----- Let me know if you need anything else.It's pretty much the same as before... (gdb) bt #0 0x00002aae16a8de44 in ldap_count_values (vals=0x559cadc0) at getvalues.c:153 #1 0x00005555555db423 in zif_ldap_get_entries (ht=1436331456, return_value=0x5555559ca5c0, return_value_ptr=0x0, this_ptr=0x0, return_value_used=1435796224) at /var/tmp/portage/php-5.1.6-r4/work/php-5.1.6/ext/ldap/ldap.c:1068 #2 0x00005555556e4d20 in zend_do_fcall_common_helper_SPEC ( execute_data=0x7fff942851d0) at zend_vm_execute.h:200 #3 0x00005555556ed112 in ZEND_DO_FCALL_SPEC_CONST_HANDLER ( execute_data=0x7fff942851d0) at zend_vm_execute.h:1640 #4 0x00005555556e43f9 in execute (op_array=0x5555559c7ae0) at zend_vm_execute.h:92 #5 0x00005555556bf1d8 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /var/tmp/portage/php-5.1.6-r4/work/php-5.1.6/Zend/zend.c:1109 #6 0x0000555555670784 in php_execute_script (primary_file=0x7fff94287790) at /var/tmp/portage/php-5.1.6-r4/work/php-5.1.6/main/main.c:1737 #7 0x00005555557756f4 in main (argc=3, argv=0x7fff942879c8) at /var/tmp/portage/php-5.1.6-r4/work/php-5.1.6/sapi/cli/php_cli.c:1093 The ldap code to reproduce the problem is the same as at the beginning of this report... The difference between the code I posted originally and the code that gave me the above output (showing "Count: 1"), is this: echo "done searching\n"; echo "Count: " . ldap_count_entries($_SERVER['ldap'],$r) . " entries\n"; $info = ldap_get_entries($_SERVER['ldap'], $r); (that is, I added the Count line *after* the original post; everything else is the same)My apologies for misunderstanding... To reproduce the problem on my system: 1) I connect to the ldap server, which happens to be a Microsoft Active Directory domain controller, using: $_SERVER['ldap'] = ldap_connect("ldap://xyzdc02.xyz.acs-inc.com") or die("ldap connect failed"); 2) Set MSAD-required options: ldap_set_option($_SERVER['ldap'], LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($_SERVER['ldap'], LDAP_OPT_REFERRALS, 0); 3) Bind to the LDAP directory with a search user configured with read access to the directory: ldap_bind($_SERVER['ldap'], 'ldsearch@xyz.acs-inc.com', 'some.Pass') or die('ldap bind failed'); 4) Perform a basic search, looking for my User object: $result = ldap_search($_SERVER['ldap'], 'dc=xyz,dc=acs-inc,dc=com', '(sAMAccountName=jhansche)', array('samaccountname','telephonenumber')); (print a couple of debug messages): echo "done searching\n"; echo "Count: " . ldap_count_entries($_SERVER['ldap'],$result) . " entries\n"; 5) Attempt to fetch the results of the search above: $info = ldap_get_entries($_SERVER['ldap'], $result); *** This was the last line to execute before the segfault *** (print more debugging messages): echo "Done fetching\n"; print_r($info); ============== I then test the script with this command line (ruling out apache as any part of the problem), and receive these results to stdout/err: # php -e test.php done searching Count: 1 entries Segmentation fault ============== As a result of that process, running via gdb, I get the backtrace, which I have posted previously. ============== Running via valgrind, filtering out the valgrind output, the script *runs fine*, and produces the following output: # valgrind php -e test.php 2>/dev/null done searching Count: 1 entries Done fetching Array ( [Full output of the array returned by ldap_get_entries() is displayed here correctly, but snipped out for brevity's sake] ) # (end of output) ============== The LDAP server is running Windows Server 2003 SP1. The segmentation fault occurs when trying to connect to either of the two domain controllers on the network. The segfault also occurs if I leave off the LDAP_OPT_REFERRALS = 0 option, and perform a single-level search directly on the Organizational Unit containing my user account. ============== /etc/openldap/ldap.conf: BASE dc=xyz,dc=acs-inc,dc=com URI ldap://xyz.acs-inc.com TLS_REQCERT never TLS_CACERT /etc/ssl/certs/xyzdc02.pem TLS_CACERTDIR /etc/ssl/certs (note that I am not calling ldap_start_tls() in this test, so the TLS_* lines are not used) ============== Performing the same query via the command-line 'ldapsearch' utility from OpenLDAP: $ ldapsearch -H ldap://xyz.acs-inc.com -D ldsearch@xyz.acs-inc.com -w some.Pass "(samaccountname=jhansche)" telephonenumber # LDAPv3 # base <> with scope subtree # filter: (samaccountname=jhansche) # requesting: telephonenumber # Joe Hansche, Administrators, elp.acs-inc.com dn: CN=Joe Hansche,OU=Administrators,DC=xyz,DC=acs-inc,DC=com telephoneNumber: 5492 ============== Unfortunately, I don't have another non-MS ldap server to try. It appears that the search is completed successfully, because the ldap_count_entries() call returns 1, which is correct. It just segfaults when trying to retrieve the actual entries with ldap_get_entries(). I hope that is more informative. If not, please let me know what additional information I can give you that might help track this problem down. If you'd like I can try adding some debugging messages into the ldap portion of the php source to see where it might be failing, and why? Thanks, by the way. I appreciate your efforts.