Wireshark-bugs: [Wireshark-bugs] [Bug 2453] segmentation fault with wslua script
Date: Wed, 30 Apr 2008 02:41:10 -0700 (PDT)
http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=2453





--- Comment #20 from LEGO <luis.ontanon@xxxxxxxxx>  2008-04-30 02:40:35 GMT ---
(In reply to comment #17)
> I don't really understand why should be there *anything* which has to be
> cleared. Lua will manage the memory and call the __gc if something has to be
> cleared. What can be cleared are the actual userdata and not the pointer itself
> (see epan/wslua/wslua.h)
> 
> If I understand the situation correctly maybe the __gc function should be
> implemented instead of reinventing the wheel with this "outstanding_stuff"
> thing.
> 

The outstanding stuff is there to avoid leaving "pointers to junk" in the lua
VM.

if the lua user copies a tvb and keeps it after the current packet that pointer
will become invalid as soon as the ws core cleans it up before the next packet.
By NULLifing it we avoid it to crash if used later.

if for example we have __gc freeing the tvb itself there's probably another 30
places Wireshark could crash when trying to use the freed tvb.

So the whole "outstanding_X thing" is there simply because the lifespan of the
Lua variable containing the object and the object itself is not related.

I agree that the best solution would be to forcefully purge variables from the
Lua VM (e.g. turn them into nil) when the underlying object is being freed or
it has become invalid; But unfortunately I'm not aware of any way to achieve
this.


-- 
Configure bugmail: http://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.