From 120f285eb71c8c2002207c57a5b1d6bedbcc632b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Thu, 5 Jul 2018 14:39:58 +0300 Subject: [PATCH 1/3] Fix Gitlab CI tests Drops the build stage in Gitlab CI tests and includes build in the test jobs. Building in a separate stage did not work as intended. The test jobs rebuilt Kvazaar without the CFLAGS given in the build jobs and overwrote the results from the build jobs. The test were therefore run without the sanitizers enabled. --- .gitlab-ci.yml | 47 ++++++++++++----------------------------------- 1 file changed, 12 insertions(+), 35 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 96f10ef1..0b9c8229 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,67 +1,44 @@ # Use Kvazaar CI base image which includes the build tools and ffmpeg + hmdec in ${HOME}/bin image: ultravideo/kvazaar_ci_base:latest -# Build kvazaar -build-kvazaar: &build-template - stage: build +# Build and test kvazaar +test-kvazaar: &test-template + stage: test script: + - export PATH="${HOME}/bin:${PATH}" - ./autogen.sh - ./configure --enable-werror || (cat config.log && false) - - make --jobs=8 V=1 + - make --jobs=8 + - make check --jobs=8 VERBOSE=1 artifacts: paths: - src/kvazaar - src/.libs expire_in: 1 week -build-asan: - <<: *build-template +test-asan: + <<: *test-template variables: CFLAGS: '-fsanitize=address' # LeakSanitizer doesn't work inside the container because it requires # ptrace so we disable it. ASAN_OPTIONS: 'detect_leaks=0' -build-tsan: - <<: *build-template +test-tsan: + <<: *test-template variables: CFLAGS: '-fsanitize=thread' -build-ubsan: - <<: *build-template +test-ubsan: + <<: *test-template variables: CFLAGS: '-fsanitize=undefined -fno-sanitize-recover=all -fno-sanitize=alignment' -.test-template: &test-template - stage: test - script: - - export PATH="${HOME}/bin:${PATH}" - - ./autogen.sh - - ./configure --enable-werror - - make check --jobs=8 VERBOSE=1 - test-valgrind: <<: *test-template - dependencies: - - build-kvazaar variables: KVAZAAR_OVERRIDE_angular_pred: generic KVAZAAR_OVERRIDE_sao_band_ddistortion: generic KVAZAAR_OVERRIDE_sao_edge_ddistortion: generic KVAZAAR_OVERRIDE_calc_sao_edge_dir: generic KVZ_TEST_VALGRIND: 1 - -test-asan: - <<: *test-template - dependencies: - - build-asan - -test-tsan: - <<: *test-template - dependencies: - - build-tsan - -test-ubsan: - <<: *test-template - dependencies: - - build-ubsan From b7474eb532e3629f9643003ae74d58da56f9718b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Thu, 5 Jul 2018 15:12:45 +0300 Subject: [PATCH 2/3] Fix SAO buffer sizes Increases sizes of buffers used for SAO reconstruction to avoid stack buffer overflow in AVX2 SAO reconstruction. --- src/encoderstate.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/encoderstate.c b/src/encoderstate.c index a423c407..25acb88a 100644 --- a/src/encoderstate.c +++ b/src/encoderstate.c @@ -37,9 +37,6 @@ #include "tables.h" #include "threadqueue.h" -#define SAO_BUF_WIDTH (LCU_WIDTH + SAO_DELAY_PX + 2) -#define SAO_BUF_WIDTH_C (SAO_BUF_WIDTH / 2) - int kvz_encoder_state_match_children_of_previous_frame(encoder_state_t * const state) { int i; @@ -250,10 +247,18 @@ static void encoder_sao_reconstruct(const encoder_state_t *const state, { videoframe_t *const frame = state->tile->frame; - // Temporary buffers for SAO input pixels. - kvz_pixel sao_buf_y_array[SAO_BUF_WIDTH * SAO_BUF_WIDTH]; - kvz_pixel sao_buf_u_array[SAO_BUF_WIDTH_C * SAO_BUF_WIDTH_C]; - kvz_pixel sao_buf_v_array[SAO_BUF_WIDTH_C * SAO_BUF_WIDTH_C]; + + // Temporary buffers for SAO input pixels. The buffers cover the pixels + // inside the LCU (LCU_WIDTH x LCU_WIDTH), SAO_DELAY_PX wide bands to the + // left and above the LCU, and one pixel border on the left and top + // sides. We add two extra pixels to the buffers because the AVX2 SAO + // reconstruction reads up to two extra bytes when using edge SAO in the + // horizontal direction. +#define SAO_BUF_WIDTH (1 + SAO_DELAY_PX + LCU_WIDTH) +#define SAO_BUF_WIDTH_C (1 + SAO_DELAY_PX/2 + LCU_WIDTH_C) + kvz_pixel sao_buf_y_array[SAO_BUF_WIDTH * SAO_BUF_WIDTH + 2]; + kvz_pixel sao_buf_u_array[SAO_BUF_WIDTH_C * SAO_BUF_WIDTH_C + 2]; + kvz_pixel sao_buf_v_array[SAO_BUF_WIDTH_C * SAO_BUF_WIDTH_C + 2]; // Pointers to the top-left pixel of the LCU in the buffers. kvz_pixel *const sao_buf_y = &sao_buf_y_array[(SAO_DELAY_PX + 1) * (SAO_BUF_WIDTH + 1)]; From 31786a9266a63c2cdfa23c84afa8b02bfc09a410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Thu, 5 Jul 2018 16:05:55 +0300 Subject: [PATCH 3/3] Fix ASan test on Gitlab CI Changes test_external_symbols.sh to expect a failure with ASan. --- .gitlab-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0b9c8229..6110e3a0 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -23,6 +23,9 @@ test-asan: # LeakSanitizer doesn't work inside the container because it requires # ptrace so we disable it. ASAN_OPTIONS: 'detect_leaks=0' + # AddressSanitizer adds some extra symbols so we expect a failure from + # the external symbols test. + XFAIL_TESTS: test_external_symbols.sh test-tsan: <<: *test-template