-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-sanitizersArea: Sanitizers for correctness and code qualityArea: Sanitizers for correctness and code qualityC-bugCategory: This is a bug.Category: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.
Description
While ThreadSanitizer models synchronization implied by IO operations, it currently doesn't have interceptor for fcntl(fd, F_DUPFD_CLOEXEC, ..)
and as a result operations on a duplicated file descriptor don't introduce synchronization. For example, the following generates a false positive report:
#![feature(sync_unsafe_cell)]
#![feature(anonymous_pipe)]
use std::cell::*;
use std::io::*;
use std::sync::*;
fn main() {
let c = Arc::new(SyncUnsafeCell::new(0));
let (mut a, mut b) = std::pipe::pipe().unwrap();
// Duplicate file descriptor. Implemented in terms of fcntl(fd, F_DUPFD_CLOEXEC, ...).
// Comment out the following line to hide the false positive.
let mut b = b.try_clone().unwrap();
let t = std::thread::spawn({
let c = c.clone();
move || {
unsafe { *c.get() = 1 };
b.write_all(b".").unwrap();
}
});
let mut buf = [0];
a.read_exact(&mut buf).unwrap();
println!("{}", unsafe { *c.get() });
t.join().unwrap();
}
This shortcoming makes ThreadSanitizer incompatible with Tokio.
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-sanitizersArea: Sanitizers for correctness and code qualityArea: Sanitizers for correctness and code qualityC-bugCategory: This is a bug.Category: This is a bug.T-libsRelevant to the library team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.