diff options
-rw-r--r-- | .ci/common.sh | 14 | ||||
-rw-r--r-- | .ci/gcc-32.sh | 2 | ||||
-rw-r--r-- | .ci/gcc.sh | 1 | ||||
-rw-r--r-- | .travis.yml | 4 | ||||
-rw-r--r-- | .valgrind.supp | 7 | ||||
-rw-r--r-- | src/nvim/msgpack_rpc/channel.c | 7 | ||||
-rw-r--r-- | src/nvim/os/event.c | 21 |
7 files changed, 42 insertions, 14 deletions
diff --git a/.ci/common.sh b/.ci/common.sh index 76faf595c8..8498d16506 100644 --- a/.ci/common.sh +++ b/.ci/common.sh @@ -7,10 +7,7 @@ asan_check() { } check_logs() { - # For some strange reason, now we need to give ubuntu some time to flush it's - # FS cache in order to see error logs, even though all commands are executing - # synchronously - sleep 1 + check_core_dumps # Iterate through each log to remove an useless warning for log in $(find "$1" -type f -name "$2"); do sed -i "$log" \ @@ -29,6 +26,15 @@ check_logs() { fi } +check_core_dumps() { + sleep 2 + local c + for c in $(find ./ -name '*core*' -print); do + gdb -q -n -batch -ex bt build/bin/nvim $c + exit 1 + done +} + set_environment() { local prefix="$1/usr" eval $($prefix/bin/luarocks path) diff --git a/.ci/gcc-32.sh b/.ci/gcc-32.sh index c128e91988..aea996f5a0 100644 --- a/.ci/gcc-32.sh +++ b/.ci/gcc-32.sh @@ -23,4 +23,6 @@ CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON \ $MAKE_CMD CMAKE_EXTRA_FLAGS="${CMAKE_EXTRA_FLAGS}" unittest $MAKE_CMD test +check_core_dumps $MAKE_CMD oldtest +check_core_dumps diff --git a/.ci/gcc.sh b/.ci/gcc.sh index 90063e48f3..b4a331cfed 100644 --- a/.ci/gcc.sh +++ b/.ci/gcc.sh @@ -11,6 +11,7 @@ export VALGRIND_LOG="$tmpdir/valgrind-%p.log" CMAKE_EXTRA_FLAGS="-DTRAVIS_CI_BUILD=ON -DUSE_GCOV=ON" $MAKE_CMD CMAKE_EXTRA_FLAGS="${CMAKE_EXTRA_FLAGS}" unittest +build/bin/nvim --version if ! $MAKE_CMD test; then valgrind_check "$tmpdir" exit 1 diff --git a/.travis.yml b/.travis.yml index 9bf7844a3e..94affe7bd6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,9 +20,9 @@ before_install: # Need xvfb for running some tests with xclip - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start - - sudo apt-get install xclip + - sudo apt-get install xclip gdb script: # This will pass the environment variables down to a bash process which runs # as $USER, while retaining the environment variables defined and belonging # to secondary groups given above in usermod. - - sudo -E su ${USER} -c "sh -e \"${CI_SCRIPTS}/${CI_TARGET}.sh\"" + - sudo -E su ${USER} -c "ulimit -c 102400; sh -e \"${CI_SCRIPTS}/${CI_TARGET}.sh\"" diff --git a/.valgrind.supp b/.valgrind.supp index f788030151..ec4bd50df5 100644 --- a/.valgrind.supp +++ b/.valgrind.supp @@ -30,3 +30,10 @@ fun:vim_strsave fun:ex_function } +{ + uv_spawn_with_optimizations + Memcheck:Leak + fun:malloc + fun:uv_spawn + fun:job_start +} diff --git a/src/nvim/msgpack_rpc/channel.c b/src/nvim/msgpack_rpc/channel.c index 10d180b3b7..c2d16d170f 100644 --- a/src/nvim/msgpack_rpc/channel.c +++ b/src/nvim/msgpack_rpc/channel.c @@ -600,11 +600,16 @@ static void close_channel(Channel *channel) if (handle) { uv_close(handle, close_cb); } else { - mch_exit(0); + event_push((Event) { .handler = on_stdio_close }, false); } } } +static void on_stdio_close(Event e) +{ + mch_exit(0); +} + static void free_channel(Channel *channel) { pmap_del(uint64_t)(channels, channel->id); diff --git a/src/nvim/os/event.c b/src/nvim/os/event.c index ecaec0b9ce..5a5da5cd63 100644 --- a/src/nvim/os/event.c +++ b/src/nvim/os/event.c @@ -39,7 +39,7 @@ typedef struct { // immediate_events: Events that should be processed after exiting libuv event // loop(to avoid recursion), but before returning from // `event_poll` -static klist_t(Event) *deferred_events, *immediate_events; +static klist_t(Event) *deferred_events = NULL, *immediate_events = NULL; void event_init(void) { @@ -68,18 +68,25 @@ void event_init(void) void event_teardown(void) { + if (!deferred_events) { + // Not initialized(possibly a --version invocation) + return; + } + channel_teardown(); job_teardown(); server_teardown(); signal_teardown(); input_stop(); input_teardown(); - do { - // This will loop forever if we leave any unclosed handles. Currently it is - // the most reliable way to use travis for verifying the no libuv-related - // bugs(which can be hard to track later) were introduced on a PR. - uv_run(uv_default_loop(), UV_RUN_DEFAULT); - } while (uv_loop_close(uv_default_loop())); + // this last `uv_run` will return after all handles are stopped, it will + // also take care of finishing any uv_close calls made by other *_teardown + // functions. + uv_run(uv_default_loop(), UV_RUN_DEFAULT); + // abort that if we left unclosed handles + if (uv_loop_close(uv_default_loop())) { + abort(); + } } // Wait for some event |