Skip to content

Instantly share code, notes, and snippets.

@wycats
Last active August 29, 2015 14:02
Show Gist options
  • Save wycats/4c5bcc40710043396f2b to your computer and use it in GitHub Desktop.
Save wycats/4c5bcc40710043396f2b to your computer and use it in GitHub Desktop.
✗ ./test RUST_BACKTRACE=1
Args { fail: false, first: hello, second: [world, and, stuff], reference: Some(Inner { text: Heyo }) }
There are not many persons who know what wonders are opened to them in the
stories and visions of their youth; for when as children we listen and dream,
we think but half-formed thoughts, and when as men we try to remember, we are
dulled and prosaic with the poison of life. But some of us awake in the night
with strange phantasms of enchanted hills and gardens, of fountains that sing
in the sun, of golden cliffs overhanging murmuring seas, of plains that stretch
down to sleeping cities of bronze and stone, and of shadowy companies of heroes
that ride caparisoned white horses along the edges of thick forests; and then
we know that we have looked back through the ivory gates into that world of
wonder which was ours before we were wise and unhappy.
fatal runtime error: assertion failed: !ptr.is_null()
stack backtrace:
1: 0x482c50 - rt::backtrace::imp::write::h6bc482a91e850a6bWrx::v0.11.0.pre
2: 0x476e00 - rt::util::abort::h7dd7892dd10f772bpLx::v0.11.0.pre
3: 0x4819d0 - rt::local_ptr::compiled::take::h12693528646470098544::v0.11.0.pre
4: 0x478d40 - rt::rtio::LocalIo<'a>::borrow::h842cb4f2d84fdb8b5bv::v0.11.0.pre
5: 0x479150 - io::stdio::src::h11364002286917177819::v0.11.0.pre
6: 0x478f70 - io::stdio::stdout::ha4a2be9b83ee5198rIp::v0.11.0.pre
7: 0x4072b0 - task::hac889e6efb06b675yha::v0.0
8: 0x404f60 - main::h4046e2c9ab0734b7Yea::v0.0
9: 0x465720 - start::closure.7884
10: 0x47e1a0 - rt::task::Task::run::closure.25247
11: 0x48c470 - rust_try
12: 0x47e0f0 - rt::task::Task::run::hda8101fd3672740eAQu::v0.11.0.pre
13: 0x465360 - start::h3ff5ebe13c0e357eqqe::v0.11.0.pre
14: 0x4652d0 - lang_start::h8e81b66aa034d05bKpe::v0.11.0.pre
15: 0x405550 - main
16: 0x7f68a0d06cf0 - __libc_start_main
17: 0x402fbd - <unknown>
18: 0x0 - <unknown>
[1] 51605 illegal hardware instruction ./test RUST_BACKTRACE=1
extern crate debug;
extern crate native;
use std::mem::transmute;
use std::rt::task::Task;
use std::rt::local::Local;
use std::any::Any;
use std::rt::task::BlockedTask;
use std::task::TaskOpts;
use std::rt::rtio::LocalIo;
use native::io::IoFactory;
struct RawUnwinder {
unwinding: bool,
cause: Option<Box<Any:Send>>
}
#[deriving(Show)]
struct Inner {
text: String
}
#[deriving(Show)]
struct Args<'a> {
fail: bool,
first: String,
second: Vec<&'static str>,
reference: Option<&'a Inner>
}
fn main() {
let inner = Inner { text: "Heyo".to_str() };
let mut args = Some(box Args { fail: false, first: "hello".to_str(), second: vec!("world", "and", "stuff"), reference: Some(&inner) });
let mut fail = Some(box Args { fail: true, first: "hello".to_str(), second: vec!(), reference: None });
task().run(|| testing(args.take_unwrap()));
task().run(|| testing(fail.take_unwrap()));
//local_unwinder_try(|| testing(args.take_unwrap()));
//local_unwinder_try(|| testing(fail.take_unwrap())).map_err(|e| println!("{}", e));
}
fn testing(args: &Args) {
if args.fail { fail!("YOLO BROLO"); }
println!("{}", args);
}
fn task() -> Box<Task> {
let mut t = Task::new();
t.put_runtime(box IoWrapper::new() as Box<std::rt::Runtime:Send>);
t.stdout = Some(box std::io::stdio::stdout() as Box<Writer:Send>);
t.stderr = Some(box std::io::stdio::stderr() as Box<Writer:Send>);
box t
}
struct IoWrapper {
io_factory: native::io::IoFactory
}
impl IoWrapper {
pub fn new() -> IoWrapper {
let mut factory = native::io::IoFactory::new();
IoWrapper { io_factory: factory }
}
}
impl std::rt::Runtime for IoWrapper {
fn yield_now(~self, cur_task: Box<Task>) { unimplemented!() }
fn maybe_yield(~self, cur_task: Box<Task>) { unimplemented!() }
fn deschedule(~self, times: uint, cur_task: Box<Task>, f: |BlockedTask| -> Result<(), BlockedTask>) { unimplemented!() }
fn reawaken(~self, to_wake: Box<Task>) { unimplemented!() }
fn spawn_sibling(~self, cur_task: Box<Task>, opts: TaskOpts, f: proc(): Send) { unimplemented!() }
fn stack_bounds(&self) -> (uint, uint) { unimplemented!() }
fn can_block(&self) -> bool { unimplemented!() }
fn wrap(~self) -> Box<Any> { unimplemented!() }
fn local_io<'a>(&'a mut self) -> Option<LocalIo<'a>> {
Some(LocalIo::new(&mut self.io_factory as &mut std::rt::rtio::IoFactory))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment