aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoy Frostig <[email protected]>2010-08-31 13:01:51 -0700
committerRoy Frostig <[email protected]>2010-08-31 13:01:57 -0700
commit47e86a05ae7c76046319e8f326f2e85de1c505b1 (patch)
treefbd7ba67c002e7d4b9546504968ed0c967b876d9 /src
parentEr, this would be the hunk that actually failed to get committed last time. (diff)
downloadrust-47e86a05ae7c76046319e8f326f2e85de1c505b1.tar.xz
rust-47e86a05ae7c76046319e8f326f2e85de1c505b1.zip
Fix rust_vec constructor assertion failure caused by slow path of upcall_vec_grow. Add testcase.
Diffstat (limited to 'src')
-rw-r--r--src/rt/rust_upcall.cpp5
-rw-r--r--src/test/run-pass/vec-append.rs17
2 files changed, 19 insertions, 3 deletions
diff --git a/src/rt/rust_upcall.cpp b/src/rt/rust_upcall.cpp
index a3373870..6f12b24d 100644
--- a/src/rt/rust_upcall.cpp
+++ b/src/rt/rust_upcall.cpp
@@ -381,7 +381,7 @@ upcall_vec_grow(rust_task *task, rust_vec *v, size_t n_bytes, uintptr_t is_gc)
LOG_UPCALL_ENTRY(task);
rust_dom *dom = task->dom;
task->log(rust_log::UPCALL|rust_log::MEM,
- "upcall vec_grow(%" PRIxPTR ", %" PRIdPTR
+ "upcall vec_grow(0x%" PRIxPTR ", %" PRIdPTR
"), alloc=%" PRIdPTR ", fill=%" PRIdPTR,
v, n_bytes, v->alloc, v->fill);
size_t alloc = next_power_of_two(sizeof(rust_vec) + v->fill + n_bytes);
@@ -411,7 +411,8 @@ upcall_vec_grow(rust_task *task, rust_vec *v, size_t n_bytes, uintptr_t is_gc)
return NULL;
}
v->deref();
- v = new (mem) rust_vec(dom, alloc, v->fill, &v->data[0]);
+ v = new (mem) rust_vec(dom, alloc, v->fill,
+ v->fill ? &v->data[0] : NULL);
}
I(dom, sizeof(rust_vec) + v->fill <= v->alloc);
return v;
diff --git a/src/test/run-pass/vec-append.rs b/src/test/run-pass/vec-append.rs
index 4324ee25..e52c6283 100644
--- a/src/test/run-pass/vec-append.rs
+++ b/src/test/run-pass/vec-append.rs
@@ -1,10 +1,25 @@
// -*- rust -*-
-fn main() {
+fn fast_growth() {
let vec[int] v = vec(1,2,3,4,5);
v += vec(6,7,8,9,0);
+
log v.(9);
check(v.(0) == 1);
check(v.(7) == 8);
check(v.(9) == 0);
}
+
+fn slow_growth() {
+ let vec[int] v = vec();
+ let vec[int] u = v;
+ v += vec(17);
+
+ log v.(0);
+ check (v.(0) == 17);
+}
+
+fn main() {
+ fast_growth();
+ slow_growth();
+}