From 079edbdd3e67109fe0e99306c0d7d560e329e1e1 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 13 Jan 2024 12:50:42 +0100 Subject: [PATCH 1/7] Try moving the dummy encoding part of gzfile_getc to another function * See https://github.com/ruby/zlib/pull/73#issuecomment-1890427228 --- ext/zlib/zlib.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index dc608ee..a885c79 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -2965,6 +2965,25 @@ gzfile_read_all(struct gzfile *gz) return gzfile_newstr(gz, dst); } +static VALUE +gzfile_getc_dummy_encoding(struct gzfile *gz) +{ + const unsigned char *ss, *sp, *se; + unsigned char *ds, *dp, *de; + VALUE cbuf = rb_enc_str_new(0, GZFILE_CBUF_CAPA, gz->enc); + + ss = sp = (const unsigned char*)RSTRING_PTR(gz->z.buf); + se = sp + ZSTREAM_BUF_FILLED(&gz->z); + ds = dp = (unsigned char *)RSTRING_PTR(cbuf); + de = (unsigned char *)ds + GZFILE_CBUF_CAPA; + (void)rb_econv_convert(gz->ec, &sp, se, &dp, de, ECONV_PARTIAL_INPUT|ECONV_AFTER_OUTPUT); + rb_econv_check_error(gz->ec); + VALUE dst = zstream_shift_buffer(&gz->z, sp - ss); + gzfile_calc_crc(gz, dst); + rb_str_resize(cbuf, dp - ds); + return cbuf; +} + static VALUE gzfile_getc(struct gzfile *gz) { @@ -2983,20 +3002,7 @@ gzfile_getc(struct gzfile *gz) } if (gz->ec && rb_enc_dummy_p(gz->enc2)) { - const unsigned char *ss, *sp, *se; - unsigned char *ds, *dp, *de; - VALUE cbuf = rb_enc_str_new(0, GZFILE_CBUF_CAPA, gz->enc); - - ss = sp = (const unsigned char*)RSTRING_PTR(gz->z.buf); - se = sp + ZSTREAM_BUF_FILLED(&gz->z); - ds = dp = (unsigned char *)RSTRING_PTR(cbuf); - de = (unsigned char *)ds + GZFILE_CBUF_CAPA; - (void)rb_econv_convert(gz->ec, &sp, se, &dp, de, ECONV_PARTIAL_INPUT|ECONV_AFTER_OUTPUT); - rb_econv_check_error(gz->ec); - dst = zstream_shift_buffer(&gz->z, sp - ss); - gzfile_calc_crc(gz, dst); - rb_str_resize(cbuf, dp - ds); - return cbuf; + return gzfile_getc_dummy_encoding(gz); } else { buf = gz->z.buf; From 18ab33d710b2ca67e872abcd67ebfddcd1e6e13f Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 13 Jan 2024 13:04:16 +0100 Subject: [PATCH 2/7] Try verbose --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 86a8e27..d51c564 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,3 +39,5 @@ jobs: - name: Run test run: bundle exec rake compile test timeout-minutes: 5 + env: + TESTOPTS: "--verbose" From 4b56a7e5ea7f605b02d988aaba93e4d4b2ab1ed1 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 13 Jan 2024 13:16:48 +0100 Subject: [PATCH 3/7] Try __noinline__ --- ext/zlib/zlib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c index a885c79..8556b48 100644 --- a/ext/zlib/zlib.c +++ b/ext/zlib/zlib.c @@ -2965,6 +2965,7 @@ gzfile_read_all(struct gzfile *gz) return gzfile_newstr(gz, dst); } +__attribute__((__noinline__)) static VALUE gzfile_getc_dummy_encoding(struct gzfile *gz) { From b418041ddc4d3d8e3d4dfb4e4aa44211e093df51 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sun, 14 Jan 2024 21:36:33 +0100 Subject: [PATCH 4/7] debug --- .github/workflows/test.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d51c564..6695c21 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,8 +36,15 @@ jobs: with: ruby-version: ${{ matrix.ruby }} bundler-cache: true # 'bundle install' and cache + - run: env | sort + - run: | + cc -xc -E - < + foo(RTLD_LAZY, RTLD_NOW, RTLD_LOCAL, RTLD_GLOBAL); + EOF - name: Run test run: bundle exec rake compile test timeout-minutes: 5 env: TESTOPTS: "--verbose" + TRUFFLERUBYOPT: "--experimental-options --cexts-log-load" From 91fdf1bfe8bf2261fa2354fb7867952f79ffef64 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sun, 14 Jan 2024 21:55:28 +0100 Subject: [PATCH 5/7] Try macOS 11 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6695c21..2b21224 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }} - os: [ ubuntu-latest, macos-latest, windows-latest ] + os: [ ubuntu-latest, macos-11, windows-latest ] include: - ruby: mswin os: windows-latest From 93836dbcd9c07ee476917b9ec8bee2f4a4156efd Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Mon, 15 Jan 2024 18:29:11 +0100 Subject: [PATCH 6/7] Try macOS 13 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2b21224..af95f89 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }} - os: [ ubuntu-latest, macos-11, windows-latest ] + os: [ ubuntu-latest, macos-13, windows-latest ] include: - ruby: mswin os: windows-latest From 39806f575b35262ecc4312a4a5d9446c2e69d8ee Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Tue, 16 Jan 2024 16:03:01 +0100 Subject: [PATCH 7/7] Try MACOSX_DEPLOYMENT_TARGET=11.0 --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index af95f89..98d4b04 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: fail-fast: false matrix: ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }} - os: [ ubuntu-latest, macos-13, windows-latest ] + os: [ ubuntu-latest, macos-latest, windows-latest ] include: - ruby: mswin os: windows-latest @@ -48,3 +48,4 @@ jobs: env: TESTOPTS: "--verbose" TRUFFLERUBYOPT: "--experimental-options --cexts-log-load" + MACOSX_DEPLOYMENT_TARGET: "11.0"