diff mbox

tests: avoid coroutine pool test crash

Message ID 1463767231-13379-1-git-send-email-stefanha@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Stefan Hajnoczi May 20, 2016, 6 p.m. UTC
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).

Reported-by: Eduardo Habkost <ehabkost@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 tests/test-coroutine.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Fam Zheng May 24, 2016, 12:29 a.m. UTC | #1
On Fri, 05/20 11:00, Stefan Hajnoczi wrote:
> 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).
> 
> Reported-by: Eduardo Habkost <ehabkost@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  tests/test-coroutine.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/tests/test-coroutine.c b/tests/test-coroutine.c
> index dd4ced9..ea7f87f 100644
> --- a/tests/test-coroutine.c
> +++ b/tests/test-coroutine.c
> @@ -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);
> -- 
> 2.5.5
> 
> 

Reviewed-by: Fam Zheng <famz@redhat.com>
Stefan Hajnoczi May 27, 2016, 9:32 p.m. UTC | #2
On Fri, May 20, 2016 at 11:00:31AM -0700, Stefan Hajnoczi wrote:
> 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).
> 
> Reported-by: Eduardo Habkost <ehabkost@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  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
diff mbox

Patch

diff --git a/tests/test-coroutine.c b/tests/test-coroutine.c
index dd4ced9..ea7f87f 100644
--- a/tests/test-coroutine.c
+++ b/tests/test-coroutine.c
@@ -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);