Skip to content

Commit 7c837b8

Browse files
committed
Correct doubly-linked list management logic; bug exposed during conversation on issue rust-lang#106.
1 parent 314b906 commit 7c837b8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/rt/rust_task.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,8 @@ rust_task::link_gc(gc_alloc *gcm) {
423423
gcm->prev = NULL;
424424
gcm->next = gc_alloc_chain;
425425
gc_alloc_chain = gcm;
426+
if (gcm->next)
427+
gcm->next->prev = gcm;
426428
}
427429

428430
void
@@ -431,6 +433,8 @@ rust_task::unlink_gc(gc_alloc *gcm) {
431433
gcm->prev->next = gcm->next;
432434
if (gcm->next)
433435
gcm->next->prev = gcm->prev;
436+
if (gc_alloc_chain == gcm)
437+
gc_alloc_chain = gcm->next;
434438
gcm->prev = NULL;
435439
gcm->next = NULL;
436440
}

0 commit comments

Comments
 (0)