Nmap Development mailing list archives

Re: Assertion error related to Lua garbage collection of nsock pcap objects


From: Daniel Miller <bonsaiviking () gmail com>
Date: Mon, 30 Jul 2012 20:25:07 -0500

On Mon, Jul 30, 2012 at 5:35 PM, Daniel Miller <bonsaiviking () gmail com> wrote:
A different solution would be to make sure that the Lua garbage collector
can reach the nsock_iod from the nse_nsock_udata. The garbage collector
follows metatable entries, and userdata can have metatables, so setting an
entry in the nse_nsock_udata's metatable would make this work. All
nse_nsock_udata objects currently share a single metatable, so this would
have to be done as a sub-table to the metatable, with keys that uniquely
identify the nse_nsock_udata object. When socket:pcap_open() is called
(l_pcap_open), a new entry in this table would be made to make the nsock_iod
object reachable. The nsock_gc function handles finalization of collected
nse_nsock_udata objects, and would be responsible for removing the object's
entry (if any) in the shared metatable, making the nsock_iod object
reachable by one less path.

This is all a bit beyond my knowledge, so I really need an expert eye
(*cough*Patrick*cough*) to make sure my theories make sense before I start
mucking with the code.

Dan

I took a little time and came up with a patch to implement the last
solution. So far, I have not been able to replicate the assertion
error, and my scan results still seem good, but I haven't done enough
debugging to feel confident that I didn't break something. Thoughts?

Dan

Attachment: nse_nsock.patch
Description:

_______________________________________________
Sent through the nmap-dev mailing list
http://cgi.insecure.org/mailman/listinfo/nmap-dev
Archived at http://seclists.org/nmap-dev/

Current thread: