Skip to content

Commit 517e389

Browse files
committed
auto merge of #12354 : alexcrichton/rust/fix-rustuv-segfault, r=cmr
The details can be found in the comments I added to the test, but the gist of it is that capturing output injects rescheduling a green task on failure, which wasn't desired for the test in question. cc #12340
2 parents 8391b71 + fd2ed71 commit 517e389

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

Diff for: src/librustuv/idle.rs

+12
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ mod test {
168168

169169
#[test] #[should_fail]
170170
fn smoke_fail() {
171+
// By default, the test harness is capturing our stderr output through a
172+
// channel. This means that when we start failing and "print" our error
173+
// message, we could be switched to running on another test. The
174+
// IdleWatcher assumes that we're already running on the same task, so
175+
// it can cause serious problems and internal race conditions.
176+
//
177+
// To fix this bug, we just set our stderr to a null writer which will
178+
// never reschedule us, so we're guaranteed to stay on the same
179+
// task/event loop.
180+
use std::io;
181+
drop(io::stdio::set_stderr(~io::util::NullWriter));
182+
171183
let (mut idle, _chan) = mk(1);
172184
idle.resume();
173185
fail!();

Diff for: src/librustuv/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ fn local_loop() -> &'static mut uvio::UvIoFactory {
433433
#[cfg(test)]
434434
mod test {
435435
use std::cast::transmute;
436-
use std::ptr;
437436
use std::unstable::run_in_bare_thread;
438437

439438
use super::{slice_to_uv_buf, Loop};

0 commit comments

Comments
 (0)