[python-ldap] segfault/Abort for operations with unbound connection

Space One space at wechall.net
Fri Mar 11 04:51:47 EST 2016


As I already told: I don't call unbind(). Nowhere. Maybe the
python-ldap-reconnection class does somehwere.
I can't remove the instance everywhere if it is not "valid" anymore -
because it might be referenced anywhere in the very large code base.
Python-ldap also doesn't provide a method to check if the connection is
currently bound.

Am 11.03.2016 um 09:48 schrieb Michael Ströder:
> Space One wrote:
>> Sorry but that change SUCKS!
> Thank you for using python-ldap.
>
>> Now we received tracebacks from our customers with this error:
>>
>>   File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 918,
>> in search_ext_s
>>     return
>> self._apply_method_s(SimpleLDAPObject.search_ext_s,*args,**kwargs)
>>   File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 865,
>> in _apply_method_s
>>     self.reconnect(self._uri,retry_max=self._retry_max,retry_delay=self._retry_delay)
>>   File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 843,
>> in reconnect
>>     SimpleLDAPObject.unbind_s(self)
>>   File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 600,
>> in unbind_s
>>     return self.unbind_ext_s(None,None)
>>   File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 591,
>> in unbind_ext_s
>>     msgid = self.unbind_ext(serverctrls,clientctrls)
>>   File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 588,
>> in unbind_ext
>>     return
>> self._ldap_call(self._l.unbind_ext,RequestControlTuples(serverctrls),RequestControlTuples(clientctrls))
>>   File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 136,
>> in __getattr__
>>     self.__class__.__name__,repr(name)
>> AttributeError: ReconnectLDAPObject has no attribute '_l'
> Do you expect anybody to draw a serious conclusion from this traceback excerpt?
>
>> We can't handle all AttributeError's - 1. it could hide a lot of other
>> errors. 2. It wouldn't be future-proof if the code changes somewhen and
>> raise something else (e.g. TypeError due to NoneType) instead or the
>> variable '_l' changes so that one cannot inspect the frame/str(exc).
>>
>> Also the question here is why the reconnection did fail but didn't raise
>> anything (our code doesn't call unbind() anywhere!).
> My customers never have this issue. Why? ;-)
>
> As said in this thread numerous times: If you invoke unbind method the
> LDAPObject instance is NOT VALID anymore. You MUST NOT use this instance later.
> Period.
>
> => Fix your code. Then AttributeError will not be raised.
>
> (python-ldap SHOULD NOT seg fault in this case so your application continues to
> run. Thanks to Petr's patch this has been fix.)
>
> Ciao, Michael.
>



More information about the python-ldap mailing list