The error occurs because basic has value 4 and get dereferenced in the following code
|
let masked = (*basic).flags & (ValueType::Mask as InternalValue); |
frame #11: 0x000000010002b258 beaver-cli`rutie::rubysys::value::Value::builtin_type::had93e7d37925a120(self=0x000000016fdea7b8) at value.rs:162:26
159 fn builtin_type(&self) -> ValueType {
160 unsafe {
161 let basic: *const RBasic = self.value as *const _;
-> 162 let masked = (*basic).flags & (ValueType::Mask as InternalValue);
163 mem::transmute(masked as u32)
164 }
165 }
(lldb) var
(rutie::rubysys::value::Value *) self = 0x000000016fdea7b8
(rb_sys::bindings::uncategorized::RBasic *) basic = 0x0000000000000004
# Caused by calling object.ty()
(lldb) up
frame #12: 0x000000010002b120 beaver-cli`rutie::rubysys::value::Value::ty::ha4f886995d7250ab(self=0x000000016fdea7b8) at value.rs:121:17
118 } else if self.is_undef() {
119 ValueType::Undef
120 } else {
-> 121 self.builtin_type()
122 }
123 } else if !self.is_test() {
124 if self.is_nil() {
(lldb)
Reproducable example
It become immediately clear to me that this happens when you try to access the object returned by Hash.at for a key that doesn't exist in the hash.
use rutie::{VM, Symbol, Hash, Object};
fn main() {
VM::init();
let hash = VM::eval("{ name: 'hello' }").unwrap();
let name = hash.try_convert_to::<Hash>().unwrap().at(&Symbol::new("name"));
println!("{:?} is {:?}", name, name.ty());
let desc = hash.try_convert_to::<Hash>().unwrap().at(&Symbol::new("desc"));
println!("{:?} is {:?}", desc, desc.ty()); // misaligned pointer dereference
}
The error occurs because
basichas value 4 and get dereferenced in the following coderutie/src/rubysys/value.rs
Line 162 in 0079a50
Reproducable example
It become immediately clear to me that this happens when you try to access the object returned by
Hash.atfor a key that doesn't exist in the hash.