mozilla/rust — Issue #1546: Invalid write with by-copy generic tuple
Author: brson
Created: 2012-01-17 05:53:58+00:00
State: open
Labels: bug, segv, unassigned

```
fn fst(+pair: (T, U)) -> T {
let (t, _) = pair;
ret t;
}

fn main() {
fst((10, 20));
}
```

```
==8450== Thread 3:
==8450== Invalid write of size 4
==8450== at 0x4C2AF5A: memset (mc_replace_strmem.c:738)
==8450== by 0x401019: fst::_7abc65a4cbab8e1d (in /home/brian/dev/rust/build/x86_64-unknown-linux-gnu/test/run-pass/test.stage1-x86_64-unknown-linux-gnu)
==8450== by 0x401154: _rust_main (in /home/brian/dev/rust/build/x86_64-unknown-linux-gnu/test/run-pass/test.stage1-x86_64-unknown-linux-gnu)
==8450== Address 0x6470700 is 0 bytes after a block of size 21,280 alloc'd
==8450== at 0x4C28F9F: malloc (vg_replace_malloc.c:236)
==8450== by 0x50C5AFA: memory_region::malloc(unsigned long, char const*, bool) (memory_region.cpp:104)
==8450== by 0x50B38F4: new_stk(rust_scheduler*, rust_task*, unsigned long) (rust_task.cpp:193)
==8450== by 0x50B4752: rust_task::rust_task(rust_scheduler*, rust_task_list*, rust_task*, char const*) (rust_task.cpp:274)
==8450== by 0x50B1BA8: rust_scheduler::create_task(rust_task*, char const*) (rust_scheduler.cpp:339)
==8450== by 0x50BA078: rust_kernel::create_task(rust_task*, char const*) (rust_kernel.cpp:157)
==8450== by 0x50AE267: rust_start (rust.cpp:88)
==8450== by 0x553230C: (below main) (libc-start.c:226)
==8450==
==8450== Invalid write of size 4
==8450== at 0x4C2AF4F: memset (mc_replace_strmem.c:738)
==8450== by 0x401019: fst::_7abc65a4cbab8e1d (in /home/brian/dev/rust/build/x86_64-unknown-linux-gnu/test/run-pass/test.stage1-x86_64-unknown-linux-gnu)
==8450== by 0x401154: _rust_main (in /home/brian/dev/rust/build/x86_64-unknown-linux-gnu/test/run-pass/test.stage1-x86_64-unknown-linux-gnu)
==8450== Address 0x6470704 is 4 bytes after a block of size 21,280 alloc'd
==8450== at 0x4C28F9F: malloc (vg_replace_malloc.c:236)
==8450== by 0x50C5AFA: memory_region::malloc(unsigned long, char const*, bool) (memory_region.cpp:104)
==8450== by 0x50B38F4: new_stk(rust_scheduler*, rust_task*, unsigned long) (rust_task.cpp:193)
==8450== by 0x50B4752: rust_task::rust_task(rust_scheduler*, rust_task_list*, rust_task*, char const*) (rust_task.cpp:274)
==8450== by 0x50B1BA8: rust_scheduler::create_task(rust_task*, char const*) (rust_scheduler.cpp:339)
==8450== by 0x50BA078: rust_kernel::create_task(rust_task*, char const*) (rust_kernel.cpp:157)
==8450== by 0x50AE267: rust_start (rust.cpp:88)
==8450== by 0x553230C: (below main) (libc-start.c:226)
```