on master help sign in
Fix order of init in MKCDATA/c

The creation of the item could cause a collection making the pointer to the closure invalid. Also, make the test slightly gentler to stop it from exhausting the default stack size on Windows.

commit08f3a5ba043c02cdc7a802b52e4764b88d53de16 authorNiklas Larsson <niklas@mm.st> dateWed 2 Mar 2016, 10:04 (11 years ago) parent9f4cda1
2 files changed+4−4
rts/idris_rts.c+2−2 test/primitives006/load-test.idr+2−2
rts/idris_rts.c+2−2
@@ -287,18 +287,18 @@ char* GETSTROFF(VAL stroff) {
287287}
288288
289289VAL MKCDATA(VM* vm, CHeapItem * item) {
290+ c_heap_insert_if_needed(vm, &vm->c_heap, item);
290291 Closure* cl = allocate(sizeof(Closure), 0);
291292 SETTY(cl, CDATA);
292293 cl->info.c_heap_item = item;
293− c_heap_insert_if_needed(vm, &vm->c_heap, item);
294294 return cl;
295295}
296296
297297VAL MKCDATAc(VM* vm, CHeapItem * item) {
298+ c_heap_insert_if_needed(vm, &vm->c_heap, item);
298299 Closure* cl = allocate(sizeof(Closure), 1);
299300 SETTY(cl, CDATA);
300301 cl->info.c_heap_item = item;
301− c_heap_insert_if_needed(vm, &vm->c_heap, item);
302302 return cl;
303303}
304304
test/primitives006/load-test.idr+2−2
@@ -39,8 +39,8 @@ alloc x i = do
3939
4040main : IO ()
4141main = do
42− -- First allocate 4096 64M arrays to break the C heap if there's a bug
43− alloc 0 4096 >>= printLn
42+ -- First allocate 1024 64M arrays to break the C heap if there's a bug
43+ alloc 0 1024 >>= printLn
4444
4545 -- Then, test Bytes
4646 traverse_ (unit n . prim__truncInt_B8) [1..n]