Skip to contentSkip to conversation

tests: avoid coroutine pool test crash

PATCH Applied Stefan Hajnoczi 3 participants 3 messages May 20, 2016 – May 27, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tests: avoid coroutine pool test crash

Skip the test_co_queue test case if the coroutine pool is not enabled. The test case does not work without the pool because it touches memory belonging to a freed coroutine (on purpose).

---
 tests/test-coroutine.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
tests/test-coroutine.c +9 -1
index dd4ced9..ea7f87f 100644
@@ -369,7 +369,15 @@ static void perf_cost(void)
 int main(int argc, char **argv)
 {
     g_test_init(&argc, &argv, NULL);
-    g_test_add_func("/basic/co_queue", test_co_queue);
+
+    /* This test assumes there is a freelist and marks freed coroutine memory
+     * with a sentinel value.  If there is no freelist this would legitimately
+     * crash, so skip it.
+     */
+    if (CONFIG_COROUTINE_POOL) {
+        g_test_add_func("/basic/co_queue", test_co_queue);
+    }
+
     g_test_add_func("/basic/lifecycle", test_lifecycle);
     g_test_add_func("/basic/yield", test_yield);
     g_test_add_func("/basic/nesting", test_nesting);
Signature · 1 line
2.5.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 35 lines · Stefan Hajnoczi

Skip the test_co_queue test case if the coroutine pool is not enabled. The test case does not work without the pool because it touches memory belonging to a freed coroutine (on purpose).

---
 tests/test-coroutine.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
tests/test-coroutine.c +9 -1
index dd4ced9..ea7f87f 100644
@@ -369,7 +369,15 @@ static void perf_cost(void)
 int main(int argc, char **argv)
 {
     g_test_init(&argc, &argv, NULL);
-    g_test_add_func("/basic/co_queue", test_co_queue);
+
+    /* This test assumes there is a freelist and marks freed coroutine memory
+     * with a sentinel value.  If there is no freelist this would legitimately
+     * crash, so skip it.
+     */
+    if (CONFIG_COROUTINE_POOL) {
+        g_test_add_func("/basic/co_queue", test_co_queue);
+    }
+
     g_test_add_func("/basic/lifecycle", test_lifecycle);
     g_test_add_func("/basic/yield", test_yield);
     g_test_add_func("/basic/nesting", test_nesting);
Signature · 1 line
2.5.5
#2 lore raw
In reply to Stefan Hajnoczi
Quoted 9 lines · Stefan Hajnoczi

Skip the test_co_queue test case if the coroutine pool is not enabled. The test case does not work without the pool because it touches memory belonging to a freed coroutine (on purpose).

---
 tests/test-coroutine.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan