-
-
Notifications
You must be signed in to change notification settings - Fork 59
Description
Refs: nodejs/node#31432 (comment)
uvwasi_fd_table_renumber() locks the file descriptor table, acquires the source and destination mutexes, performs the renumber operation, releases the mutexes, and unlocks the file descriptor table.
An operation that takes two file descriptors (such as uvwasi_path_rename()) could have acquired one of its fd mutex locks, but not the other. If uvwasi_fd_table_renumber() is called during this window of time, deadlock can occur (uvwasi_fd_table_renumber() waits for the mutex that uvwasi_path_rename() has, and uvwasi_path_rename() waits for the file descriptor table lock that uvwasi_fd_table_renumber() has).
The file descriptor table API could add lock and unlock APIs so that calls like uvwasi_path_rename() can acquire everything at once.