Workaround an exit issue 69/20869/1
authorJosé Bollo <jose.bollo@iot.bzh>
Fri, 15 Feb 2019 16:40:04 +0000 (17:40 +0100)
committerJosé Bollo <jose.bollo@iot.bzh>
Tue, 2 Apr 2019 07:58:49 +0000 (09:58 +0200)
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  <signal handler called>
 #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 <jose.bollo@iot.bzh>
coverage/scripts/run-test.sh
coverage/scripts/zz-exit.sh [new file with mode: 0644]

index ee0fb00..fc45515 100755 (executable)
@@ -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 (file)
index 0000000..86936c7
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+$R/bin/afb-client -s -e $WSURL <<EOC
+hello exit 0
+hello exit 0
+EOC
+