summaryrefslogtreecommitdiffstats
path: root/tests/test-coroutine.c
diff options
context:
space:
mode:
authorKevin Wolf2016-08-10 13:06:55 +0200
committerKevin Wolf2016-09-05 19:06:48 +0200
commit980e66216ffc3e37903f979e02c5f63152b518c3 (patch)
tree4543128dd0072611dc5c92d911ab553a279c0524 /tests/test-coroutine.c
parentqemu-iotests: add vmdk for test backup compression in 055 (diff)
downloadqemu-980e66216ffc3e37903f979e02c5f63152b518c3.tar.gz
qemu-980e66216ffc3e37903f979e02c5f63152b518c3.tar.xz
qemu-980e66216ffc3e37903f979e02c5f63152b518c3.zip
test-coroutine: Fix coroutine pool corruption
The test case overwrites the Coroutine object with 0xff as a way to assert that the coroutine isn't used any more. However, this means that the coroutine pool now contains a corrupted object and later test cases may get this corrupted object and crash. This patch saves the real content of the object and restores it after completing the test. The only use of the coroutine pool between those two points is the deletion of co2. As this only means an insertion at the head of an SLIST (release_pool or alloc_pool), it doesn't access the invalid list pointers that co1 has during this period. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'tests/test-coroutine.c')
-rw-r--r--tests/test-coroutine.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/test-coroutine.c b/tests/test-coroutine.c
index ee5e06d327..6431dd6d7c 100644
--- a/tests/test-coroutine.c
+++ b/tests/test-coroutine.c
@@ -139,13 +139,20 @@ static void test_co_queue(void)
{
Coroutine *c1;
Coroutine *c2;
+ Coroutine tmp;
c2 = qemu_coroutine_create(c2_fn, NULL);
c1 = qemu_coroutine_create(c1_fn, c2);
qemu_coroutine_enter(c1);
+
+ /* c1 shouldn't be used any more now; make sure we segfault if it is */
+ tmp = *c1;
memset(c1, 0xff, sizeof(Coroutine));
qemu_coroutine_enter(c2);
+
+ /* Must restore the coroutine now to avoid corrupted pool */
+ *c1 = tmp;
}
/*