Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The previous CC implementation traced the memory graph via a simple recursive loop. This works fine for well-parallelized benchmarks, where it's essential to avoid deep data structures to ensure good span. But of course, it's not difficult to cook up an example to blow up the C stack during CC and lead to a crash.
This patch fixes the issue with an explicit work list, where work is enqueued onto the list, and we loop over the list to trace the memory graph. The work-list data structure is a simple list-of-chunks with LIFO ordering. We amortize additions and deletions by allocating and freeing chunks on demand.
After some initial testing, it doesn't look like this affects the performance of CC too much (both time and space), which is expected. It just removes the bad worst-case behavior.