https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=5575
--- Comment #12 from Robert G. Jakabosky <bobby@xxxxxxxxxxxxxxx> 2011-11-06 01:43:07 PST ---
(In reply to comment #11)
> (In reply to comment #6)
> > Created an attachment (id=7371)
--> (https://bugs.wireshark.org/bugzilla/attachment.cgi?id=7371) [details]
[details]
> > Fix memory errors in Lua dissectors.
>
> I just had a look at this patch. Do we really need to introduce the TvbRange
> cleanup routines? I would like to change the g_malloc in new_TvbRange() to
> ep_alloc instead of introducing this. What do you think?
As-is ep_alloc can't be used for the userdata values that are pushed into the
Lua state, since the memory may be de-allocated before the userdata value is
GC'ed. Even if a full GC is done at the end of each frame (this would be very
slow), there is no guarantee that all the userdata values had been GC'ed.
When I created the first patch for the memory errors, I didn't fully understand
the reason for the clear_outstanding_* logic, and had just used the same logic
for the TvbRange values to fix the access after free memory errors.
The clear_outstanding_* logic could be changed to invalid the userdata values
in the Lua state before they are GC'ed. Basically the userdata values
(Tvb,TvbRange,Pinfo,TreeInfo,etc...) can be nulled at the end of a frame. This
would allow ep_alloc() to be used for those datastructures. This can only be
done for values that the Lua dissector shouldn't be allowed to keep references
to after each frame. To do this a Lua table would be stored in the Lua
registry that will hold a reference to all frame invalided userdata values.
Those userdata values would be nulled at the end of a frame. If a Lua
dissector tries to access one of those values after it had been invalided, a
Lua error can be raised.
> Why did you add col_clear before col_add_str? I don't think they are needed.
I think those are remnants from when I was updating the patches to the latest
svn revision. Those memory errors had been fixed by other people in revisions
34618 & 35795. They can be removed.
--
Configure bugmail: https://bugs.wireshark.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are watching all bug changes.