Skip to content
This repository was archived by the owner on Sep 30, 2026. It is now read-only.

Fix ABBA deadlock in bufferCompleted when verbose logging is enabled - #1346

Closed
styusuf wants to merge 1 commit into
pytorch:mainfrom
styusuf:export-D99314699
Closed

styusuf wants to merge 1 commit into
pytorch:mainfrom
styusuf:export-D99314699

Conversation

@styusuf

@styusuf styusuf commented Apr 2, 2026

Copy link
Copy Markdown

Summary:
Move cuptiActivityGetNumDroppedRecords() outside the mutex_ scope in
bufferCompleted(). When VLOG_IS_ON(1), this call re-enters CUPTI and needs
its internal rwlock, while bufferRequested() acquires mutex_ under that same
rwlock - creating a deadlock in multi-threaded environments (free-threaded
Python / no-GIL).

This follows the same pattern already used in activityBuffers() and
clearActivities(), which explicitly release mutex_ before CUPTI calls with
the comment: "Can't hold mutex_ during this call".

Reviewed By: ngimel

Differential Revision: D99314699

Summary:
Move cuptiActivityGetNumDroppedRecords() outside the mutex_ scope in
bufferCompleted(). When VLOG_IS_ON(1), this call re-enters CUPTI and needs
its internal rwlock, while bufferRequested() acquires mutex_ under that same
rwlock - creating a deadlock in multi-threaded environments (free-threaded
Python / no-GIL).

This follows the same pattern already used in activityBuffers() and
clearActivities(), which explicitly release mutex_ before CUPTI calls with
the comment: "Can't hold mutex_ during this call".

Reviewed By: ngimel

Differential Revision: D99314699
@meta-codesync

meta-codesync Bot commented Apr 2, 2026

Copy link
Copy Markdown

@styusuf has exported this pull request. If you are a Meta employee, you can view the originating Diff in D99314699.

@meta-cla meta-cla Bot added the cla signed label Apr 2, 2026
@styusuf styusuf closed this Apr 2, 2026
cmcgill2 pushed a commit to cmcgill2/kineto that referenced this pull request Apr 2, 2026
…ytorch#1346)

Summary:

Move cuptiActivityGetNumDroppedRecords() outside the mutex_ scope in
bufferCompleted(). When VLOG_IS_ON(1), this call re-enters CUPTI and needs
its internal rwlock, while bufferRequested() acquires mutex_ under that same
rwlock - creating a deadlock in multi-threaded environments (free-threaded
Python / no-GIL).

This follows the same pattern already used in activityBuffers() and
clearActivities(), which explicitly release mutex_ before CUPTI calls with
the comment: "Can't hold mutex_ during this call".

Reviewed By: ngimel

Differential Revision: D99314699
meta-codesync Bot pushed a commit that referenced this pull request Apr 3, 2026
…1347)

Summary:
Pull Request resolved: #1347

Pull Request resolved: #1346

Move cuptiActivityGetNumDroppedRecords() outside the mutex_ scope in
bufferCompleted(). When VLOG_IS_ON(1), this call re-enters CUPTI and needs
its internal rwlock, while bufferRequested() acquires mutex_ under that same
rwlock - creating a deadlock in multi-threaded environments (free-threaded
Python / no-GIL).

This follows the same pattern already used in activityBuffers() and
clearActivities(), which explicitly release mutex_ before CUPTI calls with
the comment: "Can't hold mutex_ during this call".

Reviewed By: ngimel

Differential Revision: D99314699

fbshipit-source-id: 0f99d4bebf8eb1431b2d43ce17a00e81c3c8d631
ani300 pushed a commit to IBM/kineto-spyre that referenced this pull request Jul 28, 2026
…(#1347)

Summary:
Pull Request resolved: pytorch/kineto#1347

Pull Request resolved: pytorch/kineto#1346

Move cuptiActivityGetNumDroppedRecords() outside the mutex_ scope in
bufferCompleted(). When VLOG_IS_ON(1), this call re-enters CUPTI and needs
its internal rwlock, while bufferRequested() acquires mutex_ under that same
rwlock - creating a deadlock in multi-threaded environments (free-threaded
Python / no-GIL).

This follows the same pattern already used in activityBuffers() and
clearActivities(), which explicitly release mutex_ before CUPTI calls with
the comment: "Can't hold mutex_ during this call".

Reviewed By: ngimel

Differential Revision: D99314699

fbshipit-source-id: 0f99d4bebf8eb1431b2d43ce17a00e81c3c8d631
Signed-off-by: Antoni Viros i Martin <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant