diff --git a/.github/workflows/modgc.yml b/.github/workflows/modgc.yml index d0a980700821a8..6cf4760a1d3cc5 100644 --- a/.github/workflows/modgc.yml +++ b/.github/workflows/modgc.yml @@ -137,8 +137,14 @@ jobs: if: ${{ matrix.test_task == 'check' && matrix.skipped_tests }} - name: Set timeout scale - run: echo "RUBY_TEST_TIMEOUT_SCALE=10" >> $GITHUB_ENV # subprocess assertion timeouts flake on slower/contended macOS runners, especially with the slower MMTk GC - if: ${{ contains(matrix.os, 'macos') }} + run: | + scale=$((os_scale * gc_scale)) + echo "RUBY_TEST_TIMEOUT_SCALE=$scale" >> "$GITHUB_ENV" + env: + # Subprocess assertion timeouts flake on slower or contended macOS + # runners and with the slower MMTk GC. + os_scale: ${{ contains(matrix.os, 'macos') && 3 || 1 }} + gc_scale: ${{ matrix.gc.name == 'mmtk' && 3 || 1 }} - name: Set up Launchable id: launchable diff --git a/ext/strscan/strscan.c b/ext/strscan/strscan.c index da02291478c3c4..1894ed7fb3088a 100644 --- a/ext/strscan/strscan.c +++ b/ext/strscan/strscan.c @@ -1862,8 +1862,13 @@ strscan_integer_at(int argc, VALUE *argv, VALUE self) return Qnil; beg = adjust_register_position(p, p->regs.beg[i]); + if (beg > S_LEN(p)) + return Qnil; end = adjust_register_position(p, p->regs.end[i]); + end = minl(end, S_LEN(p)); len = end - beg; + if (len == 0) + return Qnil; ptr = S_PBEG(p) + beg; #ifdef HAVE_RB_INT_PARSE_CSTR { diff --git a/test/strscan/test_stringscanner.rb b/test/strscan/test_stringscanner.rb index 96a1badb1f1087..966d62b22689b8 100644 --- a/test/strscan/test_stringscanner.rb +++ b/test/strscan/test_stringscanner.rb @@ -578,6 +578,26 @@ def test_integer_at_base_auto assert_integer_at(s, 0, 0) # 0xaf end + def test_integer_at_shrunk + omit("not supported on TruffleRuby") if RUBY_ENGINE == "truffleruby" + + s = create_string_scanner(+"before 29 after") + s.skip_until(" ") + assert_equal("29", s.scan(/\d+/)) + s.string.replace("before ") + assert_nil(s.integer_at(0)) + end + + def test_integer_at_shrunk_partial + omit("not supported on TruffleRuby") if RUBY_ENGINE == "truffleruby" + + s = create_string_scanner(+"before 29 after") + s.skip_until(" ") + assert_equal("29", s.scan(/\d+/)) + s.string.replace("before 2") + assert_integer_at(s, 2) + end + def test_pre_match s = create_string_scanner('a b c d e') s.scan(/\w/) diff --git a/win32/Makefile.sub b/win32/Makefile.sub index 4f95c10bcb5690..d7b2218d9b7a06 100644 --- a/win32/Makefile.sub +++ b/win32/Makefile.sub @@ -952,6 +952,7 @@ s,@SHELL@,$$(COMSPEC),;t t s,@BUILD_FILE_SEPARATOR@,\,;t t s,@PATH_SEPARATOR@,;,;t t s,@CFLAGS@,$(CFLAGS),;t t +s,@warnflags@,$(WARNFLAGS),;t t s,@WERRORFLAG@,$(WERRORFLAG),;t t s,@DEFS@,$(DEFS),;t t s,@CPPFLAGS@,$(CPPFLAGS),;t t