Description
Hi everyone
I've tried for a couple of hours to reduce a segfault I'm seeing in pure rust code, but I can't manage it.
I'm compiling these files together:
https://raw.github.com/grahame/rust-csv/master/csv.rc
https://raw.github.com/grahame/rust-csv/master/csv.rs
https://raw.github.com/grahame/limerick/master/sim.rs
Then running the program, eg:
./sim data
where data is a directory containing a gtfs dataset, eg.
http://www.transperth.wa.gov.au/TimetablePDFs/GoogleTransit/google_transit.zip
I'm seeing a segfault in the no_overwrite function (sim.rs):
fn no_overwrite<T: copy, U: copy>(m: map::hashmap<T, U>, k: T, v: U) {
//log(error, (k, v));
let ck = k;
let cv = v;
m.insert(ck, cv);
}
but only if I remove the "let ck" and "let cv" lines, and just use k and v directly. Those lines fix up the crash if present, as does chucking in a log(error, (k, v));
.
A traceback on my mac (using rust 1d7d5c1):
rustc -g -L ../rust-csv/ ../rust-csv/csv.rc
rustc -g -L ../rust-csv/ sim.rs
(gdb) r ./data
Starting program: /Users/grahame/code/limerick/sim ./data
Reading symbols for shared libraries ...+................................................................. done
loading file: agency.txt
loading file: stops.txt
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000001
[Switching to process 10651 thread 0x1f03]
0x0000000100004080 in glue_take10 ()
(gdb) bt
#0 0x0000000100004080 in glue_take10 ()
#1 0x0000000100516b00 in ?? ()
#2 0x00000001000130fd in glue_take1407 ()
#3 0x000000010000f333 in insert () at sim.rs:1
#4 0x0000000100028b85 in __morestack ()
Previous frame inner to this frame (gdb could not unwind past this frame)