HeapSnapshot::finalize() assumes that its vector of cells are unique and have no duplicates. HeapSnapshot::appendNode() expects to only be called once for a cell, and hence, will not be adding a duplicate cell. It doesn't check for duplicates. However, with the concurrent GC marker, there’s a racy chance that the same cell is visited more than once by SlotVisitor, and therefore calls HeapSnapshotBuilder::analyzeNode() (and HeapSnapshot::appendNode()) more than once for the same cell. The easiest and cleanest fix for this is to simply keep a HashSet of appended cells in HeapSnapshotBuilder while it is building the snapshot. We can then use the hash set to filter out already appended cells, and avoid adding duplicates to the HeapSnapshot. <rdar://problem/60974478>
Created attachment 395300 [details] proposed patch.
Comment on attachment 395300 [details] proposed patch. r=me.
Thanks for the review. Landed in r259418: <http://trac.webkit.org/r259418>.