From 1defef06d0f8661db0f34da5c9080cc75e0564d0 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Mon, 11 Mar 2024 16:55:25 +0100 Subject: [PATCH 1/2] Add a timeout in CI and enable verbose tests for truffleruby * To investigate hangs like https://github.com/Shopify/liquid-c/actions/runs/8191329021/job/22400306482 --- .github/workflows/liquid.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/liquid.yml b/.github/workflows/liquid.yml index 082ef3a2..bbd17139 100644 --- a/.github/workflows/liquid.yml +++ b/.github/workflows/liquid.yml @@ -3,6 +3,7 @@ on: [push, pull_request] jobs: test: runs-on: ubuntu-latest + timeout-minutes: 10 strategy: matrix: include: @@ -31,6 +32,7 @@ jobs: continue-on-error: ${{ matrix.allowed-failure }} env: LIQUID_C_PEDANTIC: 'true' + TEST_OPTS: '-v -s0' if: matrix.ruby == 'truffleruby-head' - run: bundle exec rubocop From f1c609b7a04a0d4592c17b333713f1da57b470f1 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Mon, 11 Mar 2024 18:34:53 +0100 Subject: [PATCH 2/2] Fix capacity computation when rb_str_capacity() returns 0 * See https://github.com/Shopify/liquid-c/pull/217#issuecomment-1989019191 --- ext/liquid_c/liquid_vm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ext/liquid_c/liquid_vm.c b/ext/liquid_c/liquid_vm.c index 9e36c136..11f49f3e 100644 --- a/ext/liquid_c/liquid_vm.c +++ b/ext/liquid_c/liquid_vm.c @@ -81,9 +81,10 @@ static void write_fixnum(VALUE output, VALUE fixnum) long capacity = rb_str_capacity(output); if (new_size > capacity) { - do { - capacity *= 2; - } while (new_size > capacity); + capacity *= 2; + if (new_size > capacity) { + capacity = new_size; + } rb_str_resize(output, capacity); } rb_str_set_len(output, new_size);