Closed
Description
Test program:
use std;
import std::map;
import map::hashmap;
type test = {
x : str,
y : str
};
fn main(args: [str]) {
let t : map::hashmap<str, test> = map::new_str_hash();
let aa = "goat";
t.insert(aa,
{ x : "blah", y : "boo" });
t.insert("budgie",
{ x : aa, y : aa });
t.insert(aa,
{ x : aa, y : aa });
}
If you compile that and run it on Mac OS, using rust 664d71f I get:
(gdb) r
Starting program: /Users/grahame/code/limerick/test
Reading symbols for shared libraries ..+................................................................. done
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
[Switching to process 37060 thread 0x1e03]
0x000000010001849c in str::hash::_31827ae260e7bf7b ()
(gdb) bt
#0 0x000000010001849c in str::hash::_31827ae260e7bf7b ()
#1 0x0000000100704dd0 in ?? ()
#2 0x000000010011fb6d in map::chained::insert::_6cad5a231a3253ac ()
#3 0x00000001000f67b5 in _ZN3map7chained7hashmap5168726insert17_76e8354b7f8b17bdE ()
#4 0x00000001000014d2 in _ZN4main17_cfc7c565861fc2bfE () at test.rs:19
#5 0x00000001000015f2 in _rust_main ()
#6 0x00000001001d7695 in task_start_wrapper (a=0x100704da0) at rust_task.cpp:184
The problem seems to be that "aa" is being stomped on in the case where it is used for both the key and as part of a struct being inserted.