This repository has been archived by the owner on Feb 15, 2021. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello! 🦀,
While scanning crates.io., we (Rust group @sslab-gatech) have noticed a soundness/memory safety issue in this crate which allows safe Rust code to trigger undefined behavior. This PR adds a small fix to resolve the issue.
Issue
It is possible to create data races by enclosing a
non-Sync type data to
ParentArc
and by accessing the enclosed datafrom multiple threads via
ChildArc
.This is possible since there is no bound on
T
of implSend
forLockWeak<T>
.Proof of Concept
I prepared a minimal example that incurs undefined behavior while using the
parc
crate with safe Rust.To observe undefined behavior, you need to run the below program in Debug mode.
Since Rc's internal
strong_count
is updated by multiple threads without synchronization,the program will terminate in either one of the following states.
strong_count
> 1strong_count
== 0When run on Ubuntu 18.04, program crashes with error:
Illegal Instruction (Core Dumped)
strong_count
== 1Solution to the issue
The issue exists due to the fact that sending
LockWeak
to multiple threads can let multiple threads concurrentlyaccess the underlying data. This PR addresses the issue by adding a
Sync
bound in theSend
impl ofLockWeak
.Please let me know if there are any concerns regarding this change, and
thank you for reviewing this PR 🐱