Early warning on double-free
Summary:
Double-frees are hard to trace down when we trash refcounts, because the second free simply decrements the trashed value. Michael had the excellent idea of leaving refcounts alone when trashing memory allocations, which led to us finding the bug in
D17352274.
This diff gets us the same early warning on double-frees while still letting us trash the entire allocation. We already check the refcount against this "too high" value when we JIT AssertRefCounts in HHIRGenerateAsserts mode, but that only catches values on the frame and stack. In this week's bug we were bitten by a double-free of a value within a container.
The assertion in memory-manager.h ensures that trashed refcounts will be caught by this check.
Reviewed By: ricklavoie
Differential Revision:
D17354372
fbshipit-source-id:
dbd4e591ba40c474e8f3ebcd3ef9ea5ad810eb8f