From cee4c0f2fd35d3c8b97acb7aa77bcb5c4025f81d Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Sun, 5 May 2024 10:09:11 -0700 Subject: [PATCH 1/2] chore(ci) upload executable and coredumps on failure --- .github/workflows/job-unit-tests.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/job-unit-tests.yml b/.github/workflows/job-unit-tests.yml index d61e5b853..ed97be703 100644 --- a/.github/workflows/job-unit-tests.yml +++ b/.github/workflows/job-unit-tests.yml @@ -118,9 +118,16 @@ jobs: os: ${{ inputs.os }} ghcr_username: ${{ github.repository_owner }} ghcr_password: ${{ secrets.TOKEN_GITHUB }} + - name: Setup coredumps location + run: | + mkdir ${{ github.workspace }}/coredumps + sudo bash -c 'echo "${{ github.workspace }}/coredumps/%e.%p.%t" > /proc/sys/kernel/core_pattern' - run: make setup - run: make - - run: make test + - name: Run make test + run: | + ulimit -c unlimited + make test - name: Run lcov id: lcov if: ${{ !env.ACT && inputs.coverage }} @@ -163,13 +170,18 @@ jobs: flags: unit - run: rm -f t/servroot/html/nginx.sock if: ${{ failure() && !env.ACT }} - - uses: actions/upload-artifact@v4 + - name: Artifacts Upload + uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} with: name: ${{ github.job }}-sha-${{ github.sha }}-run-${{ github.run_number }}-${{ inputs.ngx != '' && format('nginx-{0}', inputs.ngx) || format('openresty-{0}', inputs.openresty) }}-${{ inputs.runtime }}-${{ inputs.module_type == 'dynamic' && 'dynamic' || 'static'}}-${{ inputs.ipc }}-${{ inputs.ssl }}-${{ inputs.debug }}-${{ inputs.hup }} path: | work/buildroot/ t/servroot* + ${{ github.workspace }}/coredumps + #- name: Setup tmate session + # if: ${{ failure() && !env.ACT }} + # uses: mxschmitt/action-tmate@v3 - name: Cleanup if: ${{ always() }} uses: ./.github/actions/cleanup From 55b5481e7cb0492aed18d4e4cfb2e60ea83b07da Mon Sep 17 00:00:00 2001 From: Thibault Charbonnier Date: Sun, 5 May 2024 15:24:36 -0700 Subject: [PATCH 2/2] fix(lib) prevent a segfault loading an empty .wat module with V8 Fixing it at the ngx-wasm-rs level produces a more descriptive error message than doing it at the C level. Fix #543 --- lib/ngx-wasm-rs/lib/wat/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ngx-wasm-rs/lib/wat/src/lib.rs b/lib/ngx-wasm-rs/lib/wat/src/lib.rs index 077ef0bd3..4ac81cacd 100644 --- a/lib/ngx-wasm-rs/lib/wat/src/lib.rs +++ b/lib/ngx-wasm-rs/lib/wat/src/lib.rs @@ -39,9 +39,13 @@ pub unsafe extern "C" fn ngx_wasm_wat_to_wasm( wat: *const wasm_byte_vec_t, wasm: *mut wasm_byte_vec_t, ) -> Option> { - let wat_slice; + let empty = Vec::new(); + let mut wat_slice = empty.as_ref(); + unsafe { - wat_slice = std::slice::from_raw_parts((*wat).data, (*wat).size); + if (*wat).size > 0 { + wat_slice = std::slice::from_raw_parts((*wat).data, (*wat).size); + } } match wabt::wat2wasm(wat_slice) {