Conversation
There was a problem hiding this comment.
Pull request overview
Adds new heap integrity validation to detect GC heap corruption and abort early, integrated into key GC lifecycle points and global tracing to surface memory/list corruption issues closer to their source.
Changes:
- Introduces
validate_heap_objects(lua_State *L, const char *where)to walkL->heap->objectsand validate node pointers/type/ownership, aborting on failure. - Calls this validation before/after heap transfer in
luaC_inherit_thread()and at multiple stages oflocal_collection(). - Adds basic corruption checks inside
trace_heap()during global tracing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Note
Medium Risk
Touches core GC and thread-heap transfer paths by adding pervasive heap validation and hard aborts on detected corruption, which could impact performance or trigger crashes if the checks misfire. The change is diagnostic-focused and doesn’t alter reclamation semantics beyond moving
finalize_deferred()earlier while still under collector block.Overview
Adds heap corruption diagnostics to the GC by introducing
validate_heap_objects()/tailq_abort()and calling them at key points in object allocation (new_obj), thread heap inheritance (luaC_inherit_thread), local GC phases (local_collection), and global heap tracing (trace_heap).The new checks validate TailQ link integrity, object type/flags, and heap ownership, and emit detailed crash logs before
abort()when corruption is detected. Also reorders local GC to runfinalize_deferred()before unblocking the collector and adds additional validation checkpoints around reclaim/free phases.Written by Cursor Bugbot for commit b47a5f5. This will update automatically on new commits. Configure here.