[Qemu-devel] [PATCH] test-char: fix AddressSanitizer failure

Paolo Bonzini posted 1 patch 4 years, 7 months ago
Test docker-clang@ubuntu failed
Test FreeBSD passed
Test checkpatch passed
Test docker-quick@centos7 failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190909130655.24495-1-pbonzini@redhat.com
There is a newer version of this series
tests/test-char.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
[Qemu-devel] [PATCH] test-char: fix AddressSanitizer failure
Posted by Paolo Bonzini 4 years, 7 months ago
The CharSocketServerTestConfig and CharSocketClientTestConfig
objects escape after they are passed to g_test_add_data_func,
but they cease existing after the scope that defines them is
closed.  Make them static to fix this issue.

Fixes: e7b6ba4186f243f149b0d8cddc129fe681ba3912
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/test-char.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/tests/test-char.c b/tests/test-char.c
index f3ebdffd87..525a476b89 100644
--- a/tests/test-char.c
+++ b/tests/test-char.c
@@ -1403,13 +1403,13 @@ int main(int argc, char **argv)
 #endif
 
 #define SOCKET_SERVER_TEST(name, addr)                                  \
-    CharSocketServerTestConfig server1 ## name =                        \
+    static CharSocketServerTestConfig server1 ## name =                 \
         { addr, false, false };                                         \
-    CharSocketServerTestConfig server2 ## name =                        \
+    static CharSocketServerTestConfig server2 ## name =                 \
         { addr, true, false };                                          \
-    CharSocketServerTestConfig server3 ## name =                        \
+    static CharSocketServerTestConfig server3 ## name =                 \
         { addr, false, true };                                          \
-    CharSocketServerTestConfig server4 ## name =                        \
+    static CharSocketServerTestConfig server4 ## name =                 \
         { addr, true, true };                                           \
     g_test_add_data_func("/char/socket/server/mainloop/" # name,        \
                          &server1 ##name, char_socket_server_test);     \
@@ -1421,17 +1421,17 @@ int main(int argc, char **argv)
                          &server4 ##name, char_socket_server_test)
 
 #define SOCKET_CLIENT_TEST(name, addr)                                  \
-    CharSocketClientTestConfig client1 ## name =                        \
+    static CharSocketClientTestConfig client1 ## name =                 \
         { addr, NULL, false, false };                                   \
-    CharSocketClientTestConfig client2 ## name =                        \
+    static CharSocketClientTestConfig client2 ## name =                 \
         { addr, NULL, true, false };                                    \
-    CharSocketClientTestConfig client3 ## name =                        \
+    static CharSocketClientTestConfig client3 ## name =                 \
         { addr, ",reconnect=1", false };                                \
-    CharSocketClientTestConfig client4 ## name =                        \
+    static CharSocketClientTestConfig client4 ## name =                 \
         { addr, ",reconnect=1", true };                                 \
-    CharSocketClientTestConfig client5 ## name =                        \
+    static CharSocketClientTestConfig client5 ## name =                 \
         { addr, NULL, false, true };                                    \
-    CharSocketClientTestConfig client6 ## name =                        \
+    static CharSocketClientTestConfig client6 ## name =                 \
         { addr, NULL, true, true };                                     \
     g_test_add_data_func("/char/socket/client/mainloop/" # name,        \
                          &client1 ##name, char_socket_client_test);     \
-- 
2.21.0


Re: [Qemu-devel] [PATCH] test-char: fix AddressSanitizer failure
Posted by Philippe Mathieu-Daudé 4 years, 7 months ago
On 9/9/19 3:06 PM, Paolo Bonzini wrote:
> The CharSocketServerTestConfig and CharSocketClientTestConfig
> objects escape after they are passed to g_test_add_data_func,
> but they cease existing after the scope that defines them is
> closed.  Make them static to fix this issue.
> 
> Fixes: e7b6ba4186f243f149b0d8cddc129fe681ba3912
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>  tests/test-char.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/tests/test-char.c b/tests/test-char.c
> index f3ebdffd87..525a476b89 100644
> --- a/tests/test-char.c
> +++ b/tests/test-char.c
> @@ -1403,13 +1403,13 @@ int main(int argc, char **argv)
>  #endif
>  
>  #define SOCKET_SERVER_TEST(name, addr)                                  \
> -    CharSocketServerTestConfig server1 ## name =                        \
> +    static CharSocketServerTestConfig server1 ## name =                 \
>          { addr, false, false };                                         \
> -    CharSocketServerTestConfig server2 ## name =                        \
> +    static CharSocketServerTestConfig server2 ## name =                 \
>          { addr, true, false };                                          \
> -    CharSocketServerTestConfig server3 ## name =                        \
> +    static CharSocketServerTestConfig server3 ## name =                 \
>          { addr, false, true };                                          \
> -    CharSocketServerTestConfig server4 ## name =                        \
> +    static CharSocketServerTestConfig server4 ## name =                 \
>          { addr, true, true };                                           \
>      g_test_add_data_func("/char/socket/server/mainloop/" # name,        \
>                           &server1 ##name, char_socket_server_test);     \
> @@ -1421,17 +1421,17 @@ int main(int argc, char **argv)
>                           &server4 ##name, char_socket_server_test)
>  
>  #define SOCKET_CLIENT_TEST(name, addr)                                  \
> -    CharSocketClientTestConfig client1 ## name =                        \
> +    static CharSocketClientTestConfig client1 ## name =                 \
>          { addr, NULL, false, false };                                   \
> -    CharSocketClientTestConfig client2 ## name =                        \
> +    static CharSocketClientTestConfig client2 ## name =                 \
>          { addr, NULL, true, false };                                    \
> -    CharSocketClientTestConfig client3 ## name =                        \
> +    static CharSocketClientTestConfig client3 ## name =                 \
>          { addr, ",reconnect=1", false };                                \
> -    CharSocketClientTestConfig client4 ## name =                        \
> +    static CharSocketClientTestConfig client4 ## name =                 \
>          { addr, ",reconnect=1", true };                                 \
> -    CharSocketClientTestConfig client5 ## name =                        \
> +    static CharSocketClientTestConfig client5 ## name =                 \
>          { addr, NULL, false, true };                                    \
> -    CharSocketClientTestConfig client6 ## name =                        \
> +    static CharSocketClientTestConfig client6 ## name =                 \
>          { addr, NULL, true, true };                                     \
>      g_test_add_data_func("/char/socket/client/mainloop/" # name,        \
>                           &client1 ##name, char_socket_client_test);     \
> 

Re: [Qemu-devel] [PATCH] test-char: fix AddressSanitizer failure
Posted by Daniel P. Berrangé 4 years, 7 months ago
On Mon, Sep 09, 2019 at 03:06:55PM +0200, Paolo Bonzini wrote:
> The CharSocketServerTestConfig and CharSocketClientTestConfig
> objects escape after they are passed to g_test_add_data_func,
> but they cease existing after the scope that defines them is
> closed.  Make them static to fix this issue.
> 
> Fixes: e7b6ba4186f243f149b0d8cddc129fe681ba3912
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  tests/test-char.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

Re: [Qemu-devel] [PATCH] test-char: fix AddressSanitizer failure
Posted by no-reply@patchew.org 4 years, 7 months ago
Patchew URL: https://patchew.org/QEMU/20190909130655.24495-1-pbonzini@redhat.com/



Hi,

This series failed the docker-quick@centos7 build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
make docker-image-centos7 V=1 NETWORK=1
time make docker-test-quick@centos7 SHOW_ENV=1 J=14 NETWORK=1
=== TEST SCRIPT END ===

libudev           no
default devices   yes

warning: Python 2 support is deprecated
warning: Python 3 will be required for building future versions of QEMU

NOTE: cross-compilers enabled:  'cc'
  GEN     x86_64-softmmu/config-devices.mak.tmp
---
  CC      tests/test-block-backend.o
  CC      tests/test-block-iothread.o
/tmp/qemu-test/src/tests/test-char.c: In function 'main':
/tmp/qemu-test/src/tests/test-char.c:1450:9: error: initializer element is not constant
         SOCKET_SERVER_TEST(tcp, &tcpaddr);
         ^
/tmp/qemu-test/src/tests/test-char.c:1450:9: error: (near initialization for 'server1tcp.addr')
/tmp/qemu-test/src/tests/test-char.c:1450:9: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1450:9: error: (near initialization for 'server2tcp.addr')
/tmp/qemu-test/src/tests/test-char.c:1450:9: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1450:9: error: (near initialization for 'server3tcp.addr')
/tmp/qemu-test/src/tests/test-char.c:1450:9: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1450:9: error: (near initialization for 'server4tcp.addr')
/tmp/qemu-test/src/tests/test-char.c:1451:9: error: initializer element is not constant
         SOCKET_CLIENT_TEST(tcp, &tcpaddr);
         ^
/tmp/qemu-test/src/tests/test-char.c:1451:9: error: (near initialization for 'client1tcp.addr')
/tmp/qemu-test/src/tests/test-char.c:1451:9: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1451:9: error: (near initialization for 'client2tcp.addr')
/tmp/qemu-test/src/tests/test-char.c:1451:9: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1451:9: error: (near initialization for 'client3tcp.addr')
/tmp/qemu-test/src/tests/test-char.c:1451:9: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1451:9: error: (near initialization for 'client4tcp.addr')
/tmp/qemu-test/src/tests/test-char.c:1451:9: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1451:9: error: (near initialization for 'client5tcp.addr')
/tmp/qemu-test/src/tests/test-char.c:1451:9: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1451:9: error: (near initialization for 'client6tcp.addr')
/tmp/qemu-test/src/tests/test-char.c:1456:5: error: initializer element is not constant
     SOCKET_SERVER_TEST(unix, &unixaddr);
     ^
/tmp/qemu-test/src/tests/test-char.c:1456:5: error: (near initialization for 'server1unix.addr')
/tmp/qemu-test/src/tests/test-char.c:1456:5: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1456:5: error: (near initialization for 'server2unix.addr')
/tmp/qemu-test/src/tests/test-char.c:1456:5: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1456:5: error: (near initialization for 'server3unix.addr')
/tmp/qemu-test/src/tests/test-char.c:1456:5: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1456:5: error: (near initialization for 'server4unix.addr')
/tmp/qemu-test/src/tests/test-char.c:1457:5: error: initializer element is not constant
     SOCKET_CLIENT_TEST(unix, &unixaddr);
     ^
/tmp/qemu-test/src/tests/test-char.c:1457:5: error: (near initialization for 'client1unix.addr')
/tmp/qemu-test/src/tests/test-char.c:1457:5: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1457:5: error: (near initialization for 'client2unix.addr')
/tmp/qemu-test/src/tests/test-char.c:1457:5: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1457:5: error: (near initialization for 'client3unix.addr')
/tmp/qemu-test/src/tests/test-char.c:1457:5: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1457:5: error: (near initialization for 'client4unix.addr')
/tmp/qemu-test/src/tests/test-char.c:1457:5: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1457:5: error: (near initialization for 'client5unix.addr')
/tmp/qemu-test/src/tests/test-char.c:1457:5: error: initializer element is not constant
/tmp/qemu-test/src/tests/test-char.c:1457:5: error: (near initialization for 'client6unix.addr')
make: *** [tests/test-char.o] Error 1
make: *** Waiting for unfinished jobs....
Traceback (most recent call last):


The full log is available at
http://patchew.org/logs/20190909130655.24495-1-pbonzini@redhat.com/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com