Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

libplist valgrind fixes

#88

First patch fixes invalid read from valgrind
Second patch fixes memory leaks

Reported by teuf · November 17th, 2009 @ 09:07 PM

State: resolved
Milestone: none
Assigned to: Jonathan Beck Jonathan Beck

Activity

  1. Martin S.
    Martin S.
    • State changed from new to open
    • Assigned user set to Jonathan Beck

    I remember that the changes in patch #2 actually had some complications in the history.

    Most of the time one creates a couple of plists and "glues" them together. Thus one has references to a couple of subnodes and perhaps a root level node.

    Now, the usual coder would free the individual subnodes created earlier and the root node.

    However, now imagiine what happens if a subnode is free'd.

    I think the issue in the early days of libplist was that in this case the subnode was not unlinked and thus g_node_destroy() on any parent node crashed as it still attempted to reference the already free'd but still linked subnode.

    Maybe this was fixed within glib or the issue has appeared in a different context but I clearly remember there have been some crasher and valgrind fun especially with g_node_unlink() and g_node_destroy().

    November 18th, 2009 @ 10:02 PM

  2. teuf
    teuf

    Here is an alternate patch that keeps the g_node_unlink. It won't solve the issue you describe since if one keep pointers "inside" the tree and frees the memory associated with these pointers, the toplevel node pointed by each of these pointers might be freed several times depending on the order in which you free the nodes. Imo the case you describe falls in the "if that hurts, don't do that" category.

    November 18th, 2009 @ 11:55 PM

  3. teuf
    teuf

    Sorry for the spam, I really meant this patch :)

    November 18th, 2009 @ 11:56 PM

  4. Jonathan Beck
    Jonathan Beck
    • Tag cleared.
    • State changed from open to resolved

    Applied, thanks

    November 19th, 2009 @ 05:17 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.