[Twisted-Python] Twisted Names - strange RuntimeError

Hi, while developing a code based on Twisted Names I'm finding myself catching RuntimeErrors like the one reported below. 2011-01-09 10:32:13+0100 [twisted.names.dns.DNSDatagramProtocol (UDP)] Unhandled Error Traceback (most recent call last): File "/usr/lib64/python2.6/site-packages/twisted/python/log.py", line 84, in callWithLogger return callWithContext({"system": lp}, func, *args, **kw) File "/usr/lib64/python2.6/site-packages/twisted/python/log.py", line 69, in callWithContext return context.call({ILogContext: newCtx}, func, *args,**kw) File "/usr/lib64/python2.6/site-packages/twisted/python/context.py", line 59, in callWithContext return self.currentContext().callWithContext(ctx, func, *args, **kw) File "/usr/lib64/python2.6/site-packages/twisted/python/context.py", line 37, in callWithContext return func(*args,**kw) --- <exception caught here> --- File "/usr/lib64/python2.6/site-packages/twisted/internet/epollreactor.py", line 220, in _doReadOrWrite why = selectable.doWrite() File "/usr/lib64/python2.6/site-packages/twisted/internet/base.py", line 1083, in doWrite raise RuntimeError, "doWrite called on a %s" % reflect.qual(self.__class__) exceptions.RuntimeError: doWrite called on a twisted.internet.udp.Port The code which produces this error is really complex and is part of an intelligence data gathering framework I'm developing for the Honeynet Project (for those interested in details please take a look at my technical blog http://buffer.antifork.org/blog/category/tip/ ). I realized that . the RuntimeError is raised really rarely (I see one of such errors every 2-3 days and during this time frame millions of DNS requests and replies are handled) . using different Twisted versions doesn't make the problem disappear (the attached traceback refers to version 10.2.0) . selecting a different reactor doesn't make the problem disappear Unfortunately I have not a test code for reproducing the issue and sincerely speaking I really don't know how to write it because this condition is so rarely met that I'm not able to understand what leads to it. I could be wrong but taking a look at twisted.internet.udp.Port I see it defines a write method so I really do not understand the reason why the BasePort doWrite method raises such error. Thanks for your attention and cheers, -- Angelo Dell'Aera 'buffer' Antifork Research, Inc. http://buffer.antifork.org Metro Olografix

On Sun, 2011-01-09 at 12:10 +0100, Angelo Dell'Aera wrote:
It seems like someone, somewhere is doing a startWriting() (or pauseProducing) on the Port object, i.e. the transport of the DatagramProtocol. Do you have any code that does startWriting/pauseProducing? I don't see any in twisted.internet.udp or twisted.names.

On Sun, 09 Jan 2011 14:54:33 -0000 exarkun@twistedmatrix.com wrote:
Jean-Paul, I can try adding the startWriting method and see what happens if needed. If you need additional details from such exception in order to better track down the issue please let me know and I'll be glad to add everything. Thanks and cheers, -- Angelo Dell'Aera 'buffer' Antifork Research, Inc. http://buffer.antifork.org Metro Olografix

On 9.1.2011 16:47, Angelo Dell'Aera wrote:
Could you also let us know which operating system and version you are using and which reactors you tried? A similar error was recently reported for poll reactor on FreeBSD (http://twistedmatrix.com/trac/ticket/4759). Regards, Ziga

On Sun, 09 Jan 2011 20:08:01 +0100 Žiga Seilnacht <ziga.seilnacht@gmail.com> wrote:
Sure. OS: Gentoo Linux (kernel 2.6.34) Twisted: 10.1.0 and10.2.0 Reactors: select (default) and epoll I tried all the possible combinations of Twisted and reactors always getting the same error. Thanks and regards, -- Angelo Dell'Aera 'buffer' Antifork Research, Inc. http://buffer.antifork.org Metro Olografix

On Sun, 09 Jan 2011 08:54:18 -0500 Itamar Turner-Trauring <itamar@itamarst.org> wrote:
Hi Itamar, I make no use of startWriting/pauseProducing in my code. I'm just creating a client.Resolver and then using its lookup* methods as suggested in the documentation at http://twistedmatrix.com/documents/current/names/examples/ I just subclassed the client.Resolver in order to define an empty connectionLost method this way class TIPResolver(client.Resolver): def __init__(self): client.Resolver.__init__(self, resolv = '/etc/resolv.conf') def connectionLost(self, protocol): pass r = TIPResolver() but nothing more than this. Thanks and cheers. PS If you need I can send you the source code off-list. -- Angelo Dell'Aera 'buffer' Antifork Research, Inc. http://buffer.antifork.org Metro Olografix

On Sun, 2011-01-09 at 12:10 +0100, Angelo Dell'Aera wrote:
It seems like someone, somewhere is doing a startWriting() (or pauseProducing) on the Port object, i.e. the transport of the DatagramProtocol. Do you have any code that does startWriting/pauseProducing? I don't see any in twisted.internet.udp or twisted.names.

On Sun, 09 Jan 2011 14:54:33 -0000 exarkun@twistedmatrix.com wrote:
Jean-Paul, I can try adding the startWriting method and see what happens if needed. If you need additional details from such exception in order to better track down the issue please let me know and I'll be glad to add everything. Thanks and cheers, -- Angelo Dell'Aera 'buffer' Antifork Research, Inc. http://buffer.antifork.org Metro Olografix

On 9.1.2011 16:47, Angelo Dell'Aera wrote:
Could you also let us know which operating system and version you are using and which reactors you tried? A similar error was recently reported for poll reactor on FreeBSD (http://twistedmatrix.com/trac/ticket/4759). Regards, Ziga

On Sun, 09 Jan 2011 20:08:01 +0100 Žiga Seilnacht <ziga.seilnacht@gmail.com> wrote:
Sure. OS: Gentoo Linux (kernel 2.6.34) Twisted: 10.1.0 and10.2.0 Reactors: select (default) and epoll I tried all the possible combinations of Twisted and reactors always getting the same error. Thanks and regards, -- Angelo Dell'Aera 'buffer' Antifork Research, Inc. http://buffer.antifork.org Metro Olografix

On Sun, 09 Jan 2011 08:54:18 -0500 Itamar Turner-Trauring <itamar@itamarst.org> wrote:
Hi Itamar, I make no use of startWriting/pauseProducing in my code. I'm just creating a client.Resolver and then using its lookup* methods as suggested in the documentation at http://twistedmatrix.com/documents/current/names/examples/ I just subclassed the client.Resolver in order to define an empty connectionLost method this way class TIPResolver(client.Resolver): def __init__(self): client.Resolver.__init__(self, resolv = '/etc/resolv.conf') def connectionLost(self, protocol): pass r = TIPResolver() but nothing more than this. Thanks and cheers. PS If you need I can send you the source code off-list. -- Angelo Dell'Aera 'buffer' Antifork Research, Inc. http://buffer.antifork.org Metro Olografix
participants (4)
-
Angelo Dell'Aera
-
exarkun@twistedmatrix.com
-
Itamar Turner-Trauring
-
Žiga Seilnacht