Fix memory leak of serialized IDs when compiled with --enable-debug.

When using --enable-debug, values keep track of the last identifier
to which they were bound by storing a ref'd ID pointer.  This could
lead to some circular dependencies in which an ID is never reclaimed
because the Val is bound to the ID and the ID is bound to the Val, with
both holding references to each other.

There might be more cases where this feature of --enable-debug caused
a leak, but it showed up in particular when running the
core.leaks.remote unit test due to the internal
SendID("peer_description") call during the handshake between remote
processes.  Other tests showed the send_id() BIF leaked more generally.

Tracking the ID last bound to a Val through just the identifier string
instead of a ref'd ID pointer fixes the leak.
This commit is contained in:
Jon Siwek 2012-08-16 15:59:26 -05:00
parent 4da209d3b1
commit a6f7fd9c87
3 changed files with 10 additions and 13 deletions

View file

@ -2897,11 +2897,6 @@ void RemoteSerializer::GotID(ID* id, Val* val)
(desc && *desc) ? desc : "not set"),
current_peer);
#ifdef USE_PERFTOOLS_DEBUG
// May still be cached, but we don't care.
heap_checker->IgnoreObject(id);
#endif
Unref(id);
return;
}