From 50deefa0f08b88b99748abd57560222744d2f8db Mon Sep 17 00:00:00 2001 From: José Bollo Date: Fri, 15 Feb 2019 17:40:04 +0100 Subject: Workaround an exit issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When running gcov the running script is sometime blocking. GDB tells: Thread 1 (Thread 0x7ff14e783b40 (LWP 1318)): #0 0x00007ff14ccf334c in __lll_lock_wait_private () from /lib64/libc.so.6 #1 0x00007ff14cc70598 in malloc () from /lib64/libc.so.6 #2 0x000000000046523a in gcov_do_dump () #3 0x00000000004653f4 in __gcov_exit () #4 0x00000000004632df in _GLOBAL__sub_D_00100_1_wrap_json_get_error_position () at ../../src/wrap-json.c:1250 #5 0x00007ff14e5b5916 in _dl_fini () from /lib64/ld-linux-x86-64.so.2 #6 0x00007ff14cc255ec in __run_exit_handlers () from /lib64/libc.so.6 #7 0x00007ff14cc2571c in exit () from /lib64/libc.so.6 #8 0x00000000004069fc in on_sigchld (signum=17, info=0x7ffc3f43fa70, uctx=0x7ffc3f43f940) at ../../src/main-afb-daemon.c:411 #9 #10 0x00007ff14cc6e527 in _int_malloc () from /lib64/libc.so.6 #11 0x00007ff14cc710a2 in calloc () from /lib64/libc.so.6 #12 0x00007ff14d454ff7 in json_object_new_int () from /lib64/libjson-c.so.4 ... It means that allocating memory in exit handlers can block! The work around here is to force the daemon to exit properly, i.e., not in a signal handler, by calling hello/exit from test script -at the very end-. Change-Id: Iee289fb1af8479628df895aac7eb021cedda4f2c Signed-off-by: José Bollo --- coverage/scripts/run-test.sh | 2 +- coverage/scripts/zz-exit.sh | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 coverage/scripts/zz-exit.sh diff --git a/coverage/scripts/run-test.sh b/coverage/scripts/run-test.sh index ee0fb00a..fc45515d 100755 --- a/coverage/scripts/run-test.sh +++ b/coverage/scripts/run-test.sh @@ -147,7 +147,7 @@ $R/bin/afb-daemon-cov \ # true life test ########################################################## mk \ -valgrind \ +vg \ --log-file=$R/valgrind.out \ --trace-children=no \ --track-fds=yes \ diff --git a/coverage/scripts/zz-exit.sh b/coverage/scripts/zz-exit.sh new file mode 100644 index 00000000..86936c7b --- /dev/null +++ b/coverage/scripts/zz-exit.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +$R/bin/afb-client -s -e $WSURL <