Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix race condition in generate_units #1056

Merged
merged 1 commit into from
Aug 25, 2023
Merged

Conversation

PReithofer
Copy link
Contributor

Enumerating over unlaunched_units.items() can cause a runtime error if the size of unlaunched_units changes during iteration. This can be avoided by acquiring the lock earlier.

Enumerating over unlaunched_units.items() can cause a runtime error
if the size of unlaunched_units changes during iteration. This can be avoided
by aquiring the lock earlier.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 25, 2023
@PReithofer
Copy link
Contributor Author

The concrete error I get is:

Exception in thread unit-generator:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/workspaces/Mephisto/mephisto/operations/task_launcher.py", line 184, in _launch_limited_units
    for unit in self.generate_units():
  File "/workspaces/Mephisto/mephisto/operations/task_launcher.py", line 161, in generate_units
    for i, item in enumerate(self.unlaunched_units.items()):
RuntimeError: dictionary changed size during iteration

I made some minimal changes to the static_react_example to reproduce this bug. You can check it out here:

https://github.com/PReithofer/Mephisto/tree/dict-size-change-bug

Copy link
Contributor

@JackUrb JackUrb left a comment

Choose a reason for hiding this comment

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

Thanks for this fix @PReithofer, makes complete sense! Launching with generators remains a functionality that is admittedly under-tested, good to see issues discovered and resolved.

@JackUrb JackUrb merged commit 9bcd52b into facebookresearch:main Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants