test-char: fix AddressSanitizer failure
PATCH 1/1 test-char: fix AddressSanitizer failure
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.
--- tests/test-char.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
tests/test-char.c +10 -10
@@ -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); \
Signature · 1 line
2.21.0
Quoted 7 lines · Paolo Bonzini
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 e7b6ba4186f243f149b0d8cddc129fe681ba3912Signed-off-by Paolo Bonzini <[email protected]>
Quoted 51 lines
--- tests/test-char.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)tests/test-char.c +10
-10@@ -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); \
Quoted 10 lines · Paolo Bonzini
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 e7b6ba4186f243f149b0d8cddc129fe681ba3912Signed-off-by Paolo Bonzini <[email protected]>--- tests/test-char.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
Regards,
Daniel
Signature · 3 lines
|: 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 :|
Patchew URL: https://patchew.org/QEMU/[email protected]/
Patchew URL: https://patchew.org/QEMU/[email protected]/
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/[email protected]/testing.docker-quick@centos7/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]