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

Michael Ströder michael at stroeder.com
Fri Mar 11 03:48:24 EST 2016

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.

=> 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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4245 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20160311/79929935/attachment.bin>

More information about the python-ldap mailing list