Last active
December 26, 2015 14:09
-
-
Save pythonesque/7163820 to your computer and use it in GitHub Desktop.
Failing with a runtime assertion on Rust 0.8 on Ubuntu 12.0.4.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#0 0x00007ffff62c9910 in __cxa_throw () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | |
#1 0x00007ffff741db0a in rust_begin_unwind (token=839147) at /home/ubuntu/rust/rust-0.8/src/rt/rust_builtin.cpp:509 | |
#2 0x00007ffff77a04a6 in rt::task::Unwinder::begin_unwind::h7c12263797ed078hEa6::v0.8 () | |
from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#3 0x00007ffff779f7d3 in sys::begin_unwind_::h89e154cd0915671ak::v0.8 () from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#4 0x00007ffff779f302 in sys::__extensions__::fail_with::anon::anon::expr_fn::aV () from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#5 0x00007ffff779f228 in c_str::ToCStr::with_c_str::hc6798931b183a7aS::v0.8 () from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#6 0x00007ffff779f2b1 in sys::__extensions__::fail_with::anon::expr_fn::aU () from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#7 0x00007ffff779f228 in c_str::ToCStr::with_c_str::hc6798931b183a7aS::v0.8 () from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#8 0x00007ffff77171d2 in sys::FailWithCause$__extensions__::fail_with::hd96679812a86c367hKaE::v0.8 () | |
from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#9 0x00007ffff775cb49 in str::StrSlice$__extensions__::char_range_at::multibyte_char_range_at::h482623b863865f4l2aV::v0.8 () | |
from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#10 0x00007ffff77b08a6 in repr::ReprVisitor::write_escaped_slice::h277bb0d2c449e729zgaG::v0.8 () | |
from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#11 0x00007ffff7719708 in repr::TyVisitor$ReprVisitor::visit_estr_slice::h4a99d7ffa7cb324a3qaO::v0.8 () | |
from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#12 0x00000000004172af in reflect::TyVisitor$MovePtrAdaptor::visit_estr_slice::h8f852ac685a7197dgkaA::v0.0 () | |
#13 0x0000000000415bd3 in _$BP$re_scope$LP$500$RP$$x20str::glue_visit::h86a16cc3e2ee9bcaT () | |
#14 0x0000000000415ac0 in repr::write_repr::heb89b55c35f22c6aO::v0.0 () | |
#15 0x00000000004158e7 in sys::log_str::hb89d1ae42a6256aN::v0.0 () | |
#16 0x0000000000415772 in unstable::extfmt::rt::conv_poly::hb3a77f253fecb0b1aM::v0.0 () | |
#17 0x0000000000415488 in main::hbe557d91c0115713ag::v0.0 () | |
#18 0x00007ffff77bd8a0 in rt::task::__extensions__::build_start_wrapper::anon::anon::expr_fn::a9 () | |
from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#19 0x00007ffff77bbdd7 in rt::task::__extensions__::run::anon::expr_fn::ar () from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#20 0x00007ffff741da93 in rust_try (f=<optimized out>, fptr=<optimized out>, env=<optimized out>) at /home/ubuntu/rust/rust-0.8/src/rt/rust_builtin.cpp:499 | |
#21 0x00007ffff77bbd0c in rt::task::Unwinder::try::h199ab8d6eb226980hEaq::v0.8 () from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#22 0x00007ffff77bbb81 in rt::task::Task::run::h199ab8d6eb226980Kjap::v0.8 () from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#23 0x00007ffff77bd48c in rt::task::__extensions__::build_start_wrapper::anon::expr_fn::a0 () | |
from /home/ubuntu/rust/src/../../../../usr/local/lib/rustc/x86_64-unknown-linux-gnu/lib/libstd-6c65cf4b443341b1-0.8.so | |
#24 0x0000000000000000 in ?? () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use phonebook::{Table, Contact}; | |
mod phonebook { | |
use std::hashmap::{HashMap, MutableMap}; | |
// use std::ptr::to_unsafe_ptr; | |
use std::fmt; | |
// type phone_number<'self> = &'self str; | |
type phone_number<'self> = &'self str; | |
type name<'self> = &'self str; | |
pub struct Contact<'self> { number: phone_number<'self> } | |
enum Entry<'self,T> { | |
Ref(&'self Entry<'self,T>), | |
Val(T) | |
} | |
// impl<'self> Clone for Contact<'self> { | |
// fn clone(&self) -> Contact<'self> { | |
// Contact { number: self.number } | |
// } | |
// } | |
pub struct Table<'self> { | |
priv inner: HashMap<name<'self>, &'self Entry<'self,Contact<'self>>> | |
} | |
pub trait ReferenceMap<K,V> { | |
fn add<'a>(&mut self, K, V) -> bool; | |
fn lookup<'a>(&'a self, K) -> Option<&'a V>; | |
fn alias<'a>(&'a mut self, K, K) -> bool; | |
fn change(&mut self, K, V) -> bool; | |
} | |
priv trait Dereferenceable<K, V> { | |
fn deref<'a>(&'a self, K) -> Option<&'a Entry<'a, V>>; | |
} | |
impl<'self, K, V, T : MutableMap<K,&'self Entry<'self,V>>> Dereferenceable<K, V> for T { | |
fn deref<'a,'b>(&'a self, key : K) -> Option<&'a Entry<'a,V>> { | |
let entry = self.find(&key); | |
//println(format!("{}", entry)); | |
//println!("%?", entry); | |
match entry { | |
Some(entry) => { | |
//println("yes"); | |
let mut ptr = *entry; | |
loop { | |
match *ptr { | |
Ref(next) => ptr = next, | |
_ => { | |
//println("no"); | |
return Some(ptr) | |
} | |
} | |
} | |
}, | |
None => None | |
} | |
} | |
} | |
// impl ReferenceMap<name, Entry<Contact>> for table { | |
// impl<K: Hash + Eq, V> ReferenceMap<K,V> for HashMap<K,~Entry<V>> { | |
// impl<K: Hash + Eq, V, T: Map<K, ~Entry<V>>> ReferenceMap<K,V> for T { | |
impl<'self, K, V, T : Dereferenceable<K,V> + MutableMap<K,&'self Entry<'self,V>>> ReferenceMap<K,V> for T { | |
fn add<'a>(&mut self, key : K, value : V) -> bool | |
{ | |
!self.contains_key(&key) && self.insert(key, &Val(value)) | |
} | |
fn lookup<'a>(&'a self, key : K) -> Option<&'a V> | |
{ | |
let opt = self.deref(key); | |
// println(opt); | |
match opt { | |
Some(&Val(ref val)) => { | |
println("text"); | |
// let s = fmt!("Hello, %?!", val); | |
// println(s); | |
Some(val) | |
}, | |
_ => None | |
// match *ptr { | |
// match unsafe { ~*to_unsafe_ptr(ptr) } { | |
// ~Val(entry) => Some(entry), | |
// Ref(next) => None, | |
// Val(ref next) => { | |
// Some(next)} | |
// _ => None | |
// }, | |
// _ => None | |
} | |
} | |
fn alias<'a>(&'a mut self, key : K, alias : K) -> bool | |
{ | |
!self.contains_key(&alias) && match self.find(&key) { | |
Some(&entry) => self.insert(alias, &Ref(entry)), | |
None => false | |
} | |
} | |
fn change(&mut self, key : K, value : V) -> bool | |
{ | |
true | |
} | |
} | |
impl<'self> Table<'self> { | |
pub fn new() -> Table<'self> { | |
Table { inner: HashMap::new() } | |
} | |
} | |
// See https://github.com/mozilla/rust/issues/5527 for why we can't do this. | |
// impl<'self> ReferenceMap<name,Contact> for Table<'self> { | |
impl<'self> Table<'self> { | |
pub fn add<'a>(&mut self, key : name<'self>, value : Contact<'self>) -> bool { | |
self.inner.add(key, value) | |
} | |
pub fn lookup(&'self self, key : name<'self>) -> Option<&'self Contact<'self>> { | |
self.inner.lookup(key) | |
} | |
pub fn alias(&'self mut self, key : name<'self>, alias : name<'self>) -> bool { | |
self.inner.alias(key, alias) | |
} | |
pub fn change(&mut self, key : name<'self>, value : Contact<'self>) -> bool { | |
self.inner.change(key, value) | |
} | |
// pub fn deref(&'self mut self, key : name<'self>) -> Option<&'self Entry<'self,Contact<'self>>> { | |
// self.inner.deref(key) | |
// } | |
} | |
} | |
fn main() { | |
let mut t = Table::new(); | |
let num = "12345"; | |
// t.add("keanu", Contact { number: "12345" }); | |
t.add("keanu", Contact { number: num }); | |
match t.lookup("keanu") { | |
Some(&Contact {number: num}) => println(format!("Testing: {}", num)), /* Note: I added the format because I wanted to make sure what I thought was happening was happening, but it still happens without the format */ | |
//_ => () | |
None => fail!("Could not find an entry for name: keanu") | |
} | |
// t.alias("keanu", "neo"); | |
// t.deref("neo"); | |
// phonebook::deref(t, "neo"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment