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 a read/write data race in the cache. #82

Merged
merged 2 commits into from
Sep 6, 2022

Conversation

klihub
Copy link
Contributor

@klihub klihub commented Sep 5, 2022

When being (re)configured, do not delay dereferencing our fsnotify.Watcher into the start()/watch() goroutine. That is not protected by the lock in Configure() and can trigger a read/write data race. Instead, dereference it while being properly locked and pass it as an argument to watch().

Fixes #81 which should fix this containerd PR once this fix gets tagged and that containerd PR is updated to use the fix.

This PR also adds a regression test with a gutted version of the containerd test case that triggered this bug.

When being (re)configured, do not delay dereferencing our
fsnotify.Watcher into the start()/watch() goroutine. That
is not protected by the lock in Configure() and can trigger
a read/write data race. Instead, dereference it while being
properly locked and pass it as an argument to watch().

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
@klihub
Copy link
Contributor Author

klihub commented Sep 5, 2022

@elezar PTAL. Once the fix is in, you should tag a new version to allow the original containerd PR to progress.

Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
@elezar
Copy link
Contributor

elezar commented Sep 5, 2022

@soulseen could you also take a look at this? I'll review it tomorrow and tag a v0.5.1.

@soulseen
Copy link

soulseen commented Sep 6, 2022

@elezar Thanks this looks good.

Copy link
Contributor

@bart0sh bart0sh left a comment

Choose a reason for hiding this comment

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

/lgtm

@bart0sh bart0sh merged commit a80a40e into cncf-tags:main Sep 6, 2022
@klihub klihub deleted the fixes/configure-refresh-race branch September 6, 2022 11:03
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.

there is a data race in CDI version v0.5.0
4 participants