Skip to content

TASK-189246 lock gc before traversing openupval#6

Open
balupillai wants to merge 2 commits intomainfrom
TASK-189246
Open

TASK-189246 lock gc before traversing openupval#6
balupillai wants to merge 2 commits intomainfrom
TASK-189246

Conversation

@balupillai
Copy link
Copy Markdown
Contributor

@balupillai balupillai commented Feb 4, 2026

Note

Medium Risk
Touches core GC/stop-the-world synchronization and upvalue lifecycle; small diff but incorrect blocking/unblocking or recursion balancing could introduce deadlocks or GC stalls under load.

Overview
Prevents a concurrency race between global GC tracing and mutation of a thread’s open-upvalue list by wrapping luaF_close and open-path luaF_freeupval unlinking with luaC_blockcollector/luaC_unblockcollector.

Adds per-thread recursion accounting to the global-trace mutator stop/start path (try_block_mutators/unblock_mutators) so nested collector-blocking operations remain balanced.

Written by Cursor Bugbot for commit a118619. This will update automatically on new commits. Configure here.

Cursor Bugbot reviewed your changes and found no issues for commit a118619

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

luaC_blockcollector(L);
unlinkupval(uv); /* remove from open list */
luaC_unblockcollector(L);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GC thread can deadlock blocking collector

High Severity

luaF_freeupval now calls luaC_blockcollector when freeing an open UpVal. This function is invoked from the GC reclamation path (reclaim_object for LUA_TUPVAL), so the collector thread can end up blocking on itself while a global trace is active (eg. intend_to_stop set / trace_rwlock held), causing a hard deadlock.

Fix in Cursor Fix in Web

@balupillai
Copy link
Copy Markdown
Contributor Author

balupillai commented Apr 3, 2026

💥⚡💥⚡💥⚡Abandon 💥⚡💥⚡💥⚡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant