Skip to content

Commit fad8af5

Browse files
radfordalexcrichton
authored andcommitted
---
yaml --- r: 110534 b: refs/heads/master c: dc49018 h: refs/heads/master v: v3
1 parent b1c1fb2 commit fad8af5

File tree

4 files changed

+9
-43
lines changed

4 files changed

+9
-43
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: e415c25bcd81dc1f9a5a3d25d9b48ed2d545336b
2+
refs/heads/master: dc49018679e75e8641c8a8bb295075ec5f247d99
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: e263ef1df7b892ed29e53313565eb05ab75e52f4
55
refs/heads/try: 597a645456b55e1c886ce15d23a192abdf4d55cf

trunk/src/libnative/io/process.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -524,37 +524,7 @@ fn spawn_process_os(config: p::ProcessConfig,
524524
Ok(..) => fail!("short read on the cloexec pipe"),
525525
};
526526
}
527-
// And at this point we've reached a special time in the life of the
528-
// child. The child must now be considered hamstrung and unable to
529-
// do anything other than syscalls really. Consider the following
530-
// scenario:
531-
//
532-
// 1. Thread A of process 1 grabs the malloc() mutex
533-
// 2. Thread B of process 1 forks(), creating thread C
534-
// 3. Thread C of process 2 then attempts to malloc()
535-
// 4. The memory of process 2 is the same as the memory of
536-
// process 1, so the mutex is locked.
537-
//
538-
// This situation looks a lot like deadlock, right? It turns out
539-
// that this is what pthread_atfork() takes care of, which is
540-
// presumably implemented across platforms. The first thing that
541-
// threads to *before* forking is to do things like grab the malloc
542-
// mutex, and then after the fork they unlock it.
543-
//
544-
// Despite this information, libnative's spawn has been witnessed to
545-
// deadlock on both OSX and FreeBSD. I'm not entirely sure why, but
546-
// all collected backtraces point at malloc/free traffic in the
547-
// child spawned process.
548-
//
549-
// For this reason, the block of code below should contain 0
550-
// invocations of either malloc of free (or their related friends).
551-
//
552-
// As an example of not having malloc/free traffic, we don't close
553-
// this file descriptor by dropping the FileDesc (which contains an
554-
// allocation). Instead we just close it manually. This will never
555-
// have the drop glue anyway because this code never returns (the
556-
// child will either exec() or invoke libc::exit)
557-
let _ = libc::close(input.fd());
527+
drop(input);
558528

559529
fn fail(output: &mut file::FileDesc) -> ! {
560530
let errno = os::errno();

trunk/src/libsync/arc.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,10 @@ impl<T: Share + Send> Clone for Arc<T> {
124124
}
125125
}
126126

127-
// FIXME(#13042): this should have T: Send, and use self.inner()
128-
impl<T> Deref<T> for Arc<T> {
127+
impl<T: Send + Share> Deref<T> for Arc<T> {
129128
#[inline]
130129
fn deref<'a>(&'a self) -> &'a T {
131-
let inner = unsafe { &*self.x };
132-
&inner.data
130+
&self.inner().data
133131
}
134132
}
135133

trunk/src/libsync/lock.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,10 @@ impl<T: Send> Mutex<T> {
231231
}
232232
}
233233

234-
// FIXME(#13042): these should both have T: Send
235-
impl<'a, T> Deref<T> for MutexGuard<'a, T> {
234+
impl<'a, T: Send> Deref<T> for MutexGuard<'a, T> {
236235
fn deref<'a>(&'a self) -> &'a T { &*self.data }
237236
}
238-
impl<'a, T> DerefMut<T> for MutexGuard<'a, T> {
237+
impl<'a, T: Send> DerefMut<T> for MutexGuard<'a, T> {
239238
fn deref_mut<'a>(&'a mut self) -> &'a mut T { &mut *self.data }
240239
}
241240

@@ -363,14 +362,13 @@ impl<'a, T: Send + Share> RWLockWriteGuard<'a, T> {
363362
}
364363
}
365364

366-
// FIXME(#13042): these should all have T: Send + Share
367-
impl<'a, T> Deref<T> for RWLockReadGuard<'a, T> {
365+
impl<'a, T: Send + Share> Deref<T> for RWLockReadGuard<'a, T> {
368366
fn deref<'a>(&'a self) -> &'a T { self.data }
369367
}
370-
impl<'a, T> Deref<T> for RWLockWriteGuard<'a, T> {
368+
impl<'a, T: Send + Share> Deref<T> for RWLockWriteGuard<'a, T> {
371369
fn deref<'a>(&'a self) -> &'a T { &*self.data }
372370
}
373-
impl<'a, T> DerefMut<T> for RWLockWriteGuard<'a, T> {
371+
impl<'a, T: Send + Share> DerefMut<T> for RWLockWriteGuard<'a, T> {
374372
fn deref_mut<'a>(&'a mut self) -> &'a mut T { &mut *self.data }
375373
}
376374

0 commit comments

Comments
 (0)