Age | Commit message (Collapse) | Author |
|
Co-authored-by: Takashi Kokubun <[email protected]>
|
|
compile.c: use putspecialobject for RubyVM::FrozenCore
[Bug #20569]
`putobject RubyVM::FrozenCore`, is not serializable, we
have to use `putspecialobject VM_SPECIAL_OBJECT_VMCORE`.
Co-authored-by: Jean Boussier <[email protected]>
|
|
[Bug #20280]
Backport of #10014.
|
|
[Bug #20180]
Backports #9624.
|
|
If you start Ruby with `--yjit-disable`, the `+YJIT` shouldn't be
added until `RubyVM::YJIT.enable` is actually called. Otherwise
it's confusing in crash reports etc.
Co-authored-by: Jean Boussier <[email protected]>
|
|
test_bignum: defined? returns String (#10880)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
didn't verify the test is working properly due to mistaken auto-merge… [Bug #20515]
bug: https://bugs.ruby-lang.org/issues/20515
follow-up: 22e4eeda6561693367fc7a00b92b90f46b09cabd
follow-up: https://github.com/ruby/ruby/pull/10875
|
|
22e4eeda6561693367fc7a00b92b90f46b09cabd,1ab7c412d2e3880a7ad233c32e93961888f8145c: [Backport #20515]
ci: Test whether GMP is working in compilers.yml (#10875)
Avoid reoccurence of [Bug #20515]
Requires https://github.com/ruby/ruby/pull/10876 since 18eaf0be905e3e251423b42d6f4e56b7cae1bc3b
bug: https://bugs.ruby-lang.org/issues/20515
RUBY_CHECK_HEADER didn't define HAVE_{header-file} (#10876)
--with-gmp is not working at all because HAVE_GMP_H
was missing since 18eaf0be90. [Bug #20515]
bug: https://bugs.ruby-lang.org/issues/20515
follow-up: https://bugs.ruby-lang.org/issues/20494
follow-up: 18eaf0be905e3e251423b42d6f4e56b7cae1bc3b
follow-up: https://github.com/ruby/ruby/pull/10805
|
|
[Bug #20094] Distinguish `begin` and parentheses
|
|
[Bug #20453] segfault in Regexp timeout
https://bugs.ruby-lang.org/issues/20228 started freeing `stk_base` to
avoid a memory leak. But `stk_base` is sometimes stack allocated (using
`xalloca`), so the free only works if the regex stack has grown enough
to hit `stack_double` (which uses `xmalloc` and `xrealloc`).
To reproduce the problem on master and 3.3.1:
```ruby
Regexp.timeout = 0.001
/^(a*)x$/ =~ "a" * 1000000 + "x"'
```
Some details about this potential fix:
`stk_base == stk_alloc` on
[init](https://github.com/ruby/ruby/blob/dde99215f2bc60c22a00fc941ff7f714f011e920/regexec.c#L1153),
so if `stk_base != stk_alloc` we can be sure we called
[`stack_double`](https://github.com/ruby/ruby/blob/dde99215f2bc60c22a00fc941ff7f714f011e920/regexec.c#L1210)
and it's safe to free. It's also safe to free if we've
[saved](https://github.com/ruby/ruby/blob/dde99215f2bc60c22a00fc941ff7f714f011e920/regexec.c#L1187-L1189)
the stack to `msa->stack_p`, since we do the `stk_base != stk_alloc`
check before saving.
This matches the check we do inside
[`stack_double`](https://github.com/ruby/ruby/blob/dde99215f2bc60c22a00fc941ff7f714f011e920/regexec.c#L1221)
|
|
Resize ary when `Array#sort!` block modifies embedded ary
In cases where `rb_ary_sort_bang` is called with a block and
tmp is an embedded array, we need to account for the block
potentially impacting the capacity of ary.
ex:
```
var_0 = (1..70).to_a
var_0.sort! do |var_0_block_129, var_1_block_129|
var_0.pop
var_1_block_129 <=> var_0_block_129
end.shift(3)
```
The above example can put the array into a corrupted state
resulting in a heap buffer overflow and possible segfault:
```
ERROR: AddressSanitizer: heap-buffer-overflow on address [...]
WRITE of size 560 at 0x60b0000034f0 thread T0 [...]
```
This commit adds a conditional to determine when the capacity
of ary has been modified by the provided block. If this is
the case, ensure that the capacity of ary is adjusted to
handle at minimum the len of tmp.
|
|
[Bug #20342] Consider wrapped load in `main` methods
|
|
Don't clear pending interrupts in the parent process. (#10365)
|
|
|
|
dc146babf47a84bbd1f176d766637d4a40327019,f23d5028059078a346efc977287b669d494a5a3f,a0f7de814ae5c299d6ce99bed5fb308a05d50ba0: [Backport #20296]
[Bug #20296] Clear errinfo when `exception: false`
[Bug #20296] Refine the test
[Bug #20296] Fix the default assertion message
|
|
[Bug #20292] Truncate embedded string to new capacity
|
|
Ensure that exiting thread invokes end-of-life behaviour. (#10039)
|
|
This should help in debugging the intermittent test failures on CI:
TestProcess#test_warmup_frees_pages [test/ruby/test_process.rb:2779]:
<201> expected but was
<202>.
|
|
[Bug #20307] Fix `Hash#update` to make frozen copy of string keys
|
|
Sometimes this file get picked up and break Ripper tests:
TestRipper::Generic#test_parse_files:test/ruby
assert_separately failed with error message
pid 63392 exit 0
| test_regexp.rb:2025: warning: character class has duplicated range
https://github.com/ruby/ruby/actions/runs/7699956651/job/20982702553#step:12:103
|
|
#20324] (#10329)
[Bug #20324] Uncomparable ranges are not overlapping
|
|
e626da82eae3d437b84d4f9ead0164d436b08e1a,f3af5ae7e6c1c096bbfe46d69de825a02b1696cf: [Backport #20311] (#10312)
Don't pin named structs defined in Ruby
[Bug #20311]
`rb_define_class_under` assumes it's called from C and that the
reference might be held in a C global variable, so it adds the
class to the VM root.
In the case of `Struct.new('Name')` it's wasteful and make
the struct immortal.
Make Struct memory leak test faster
[Bug #20311]
It times out on some platform, so we can reduce iterations.
On my machine it completes in 250ms and RSS grows 8X.
|
|
081ee3d35509110f383cb7dd8d1205def0cdd1e8,1c97abaabae6844c861705fd07f532292dcffa74: [Backport #19907] (#10315)
Add memory leak test for eval kwargs
De-dup identical callinfo objects
Previously every call to vm_ci_new (when the CI was not packable) would
result in a different callinfo being returned this meant that every
kwarg callsite had its own CI.
When calling, different CIs result in different CCs. These CIs and CCs
both end up persisted on the T_CLASS inside cc_tbl. So in an eval loop
this resulted in a memory leak of both types of object. This also likely
resulted in extra memory used, and extra time searching, in non-eval
cases.
For simplicity in this commit I always allocate a CI object inside
rb_vm_ci_lookup, but ideally we would lazily allocate it only when
needed. I hope to do that as a follow up in the future.
|
|
#20327] (#10313)
[Bug #20327] Do not count subsecond to calculate UTC offset
Assume that there will never be any time zones with UTC offsets that
are subseconds. Historically, UTC offset has only been used down to
the second.
|
|
d19d683a354530a27b4cbb049223f8dc70c75849,de1a586ecc2ee7f465f0c0a69291054136a3a819: [Backport #20250] (#10308)
rb_obj_setup: do not copy RUBY_FL_SEEN_OBJ_ID
[Bug #20250]
We're seting up a new instance, so it never had an associated
object_id.
proc.c: get rid of `CLONESETUP`
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[Bug #20253]
All the way down to Ruby 1.9, `Proc`, `Method`, `UnboundMethod`
and `Binding` always had their own specific clone and dup routine.
This caused various discrepancies with how other objects behave
on `dup` and `clone. [Bug #20250], [Bug #20253].
This commit get rid of `CLONESETUP` and use the the same codepath
as all other types, so ensure consistency.
NB: It's still not accepting the `freeze` keyword argument on `clone`.
Co-Authored-By: Étienne Barrié <[email protected]>
|
|
18ee7c9a108bf3424814565377c8796e5e455cf7,4a6384ed9358e8fb8464f6e37efb5477182f01db: [Backport #20246] (#10309)
Clear all refined CCs on reopening refinement mod
In cfd7729ce7a31c8b6ec5dd0e99c67b2932de4732 we started using inline
caches for refinements. However, we weren't clearing inline caches when
defined on a reopened refinement module.
Fixes [Bug #20246]
Fix [Bug #20246]: Don't set next_head_exact if a capture is called (#9897)
|
|
#20245] (#10307)
Fix crash when checking symbol encoding
[Bug #20245]
We sometimes pass in a fake string to sym_check_asciionly. This can crash
if sym_check_asciionly raises because it creates a CFP with the fake
string as the receiver which will crash if GC tries to mark the CFP.
For example, the following script crashes:
GC.stress = true
Object.const_defined?("\xC3")
|
|
#20207] (#10299)
Correctly handle consecutive lookarounds (#9738)
Fix [Bug #20207]
Fix [Bug #20212]
Handling consecutive lookarounds in init_cache_opcodes is buggy, so it
causes invalid memory access reported in [Bug #20207] and [Bug #20212].
This fixes it by using recursive functions to detected lookarounds
nesting correctly.
|
|
01bfd1a2bf013a9ed92a9722ac5228187e05e6a8,1c120efe02d079b0a1dea573cf0fd7978d9cc857,31378dc0969f4466b2122d730b7298dd7004acdf: [Backport #20228] (#10301)
Fix memory leak in OnigRegion when match raises
[Bug #20228]
rb_reg_onig_match can raise a Regexp::TimeoutError, which would cause
the OnigRegion to leak.
Fix memory leak in stk_base when Regexp timeout
[Bug #20228]
If rb_reg_check_timeout raises a Regexp::TimeoutError, then the stk_base
will leak.
Add memory leak test for Regexp timeout
[Bug #20228]
|
|
#20190] (#10300)
Fix coderange of invalid_encoding_string.<<(ord)
Appending valid encoding character can change coderange from invalid to valid.
Example: "\x95".force_encoding('sjis')<<0x5C will be a valid string "\x{955C}"
|
|
#20213] (#10297)
Fix incorrect use of VM_CALL_KW_SPLAT_MUT in zsuper with keyword splat
For zsuper calls with a keyword splat but no actual keywords, the
keyword splat is passed directly, so it cannot be mutable, because
if the callee accepts a keyword splat, changes to the keyword splat
by the callee would be reflected in the caller.
While here, simplify the logic when the method supports
literal keywords. I don't think it is possible for
a method with has_kw param flags to not have keywords, so add an
assertion for that, and set VM_CALL_KW_SPLAT_MUT in a single place.
|
|
#20194] (#10295)
Memory leak with TracePoint on bmethod
[Bug #20194]
When disabling the TracePoint on bmethod, the hooks list is not freed.
For example:
obj = Object.new
obj.define_singleton_method(:foo) {}
bmethod = obj.method(:foo)
tp = TracePoint.new(:return) {}
10.times do
100_000.times do
tp.enable(target: bmethod) {}
end
puts `ps -o rss= -p #{$$}`
end
Before:
18208
22832
26528
29728
34000
37776
40864
44400
47680
51504
After:
16688
17168
17168
17248
17696
17760
17824
17824
17856
17920
---
test/ruby/test_settracefunc.rb | 13 +++++++++++++
vm_trace.c | 1 +
2 files changed, 14 insertions(+)
|
|
#20098] (#10298)
Fix [Bug #20098]: set counter value for {n,m} repetition correctly (#9391)
|
|
merge revision(s) 2cc7a56e,b0711b1,db5d9429: [Backport #20209]
YJIT: Avoid leaks by skipping objects with a singleton class
For receiver with a singleton class, there are multiple vectors YJIT can
end up retaining the object. There is a path in jit_guard_known_klass()
that bakes the receiver into the code, and the object could also be kept
alive indirectly through a path starting at the CME object baked into
the code.
To avoid these leaks, avoid compiling calls on objects with a singleton
class.
See: https://github.com/Shopify/ruby/issues/552
[Bug #20209]
---
yjit/bindgen/src/main.rs | 1 +
yjit/src/codegen.rs | 17 +++++++++++++++++
yjit/src/cruby_bindings.inc.rs | 1 +
yjit/src/stats.rs | 2 ++
4 files changed, 21 insertions(+)
YJIT: Fix tailcall and JIT entry eating up FINISH frames (#9729)
Suppose YJIT runs a rb_vm_opt_send_without_block()
fallback and the control frame stack looks like:
```
will_tailcall_bar [FINISH]
caller_that_used_fallback
```
will_tailcall_bar() runs in the interpreter and sets up a tailcall.
Right before JIT_EXEC() in the `send` instruction, the stack will look like:
```
bar [FINISH]
caller_that_used_fallback
```
Previously, JIT_EXEC() ran bar() in JIT code, which caused the `FINISH`
flag to return to the interpreter instead of to the JIT code running
caller_that_used_fallback(), causing code to run twice and probably
crash. Recent flaky failures on CI about "each stub expects a particular
iseq" are probably due to leaving methods twice in
`test_optimizations.rb`.
Only run JIT code from the interpreter if a new frame is pushed.
---
test/ruby/test_optimization.rb | 11 +++++++++++
vm_exec.h | 3 ++-
2 files changed, 13 insertions(+), 1 deletion(-)
YJIT: No need to RESTORE_REG now that we reject tailcalls
Thanks to Kokubun for noticing.
Follow-up: b0711b1cf152afad0a480ee2f9bedd142a0d24ac
---
vm_exec.h | 1 -
1 file changed, 1 deletion(-)
|
|
#20150] (#10253)
Fix memory leak in grapheme clusters
[Bug #20150]
String#grapheme_cluters and String#each_grapheme_cluster leaks memory
because if the string is not UTF-8, then the created regex will not
be freed.
For example:
str = "hello world".encode(Encoding::UTF_32LE)
10.times do
1_000.times do
str.grapheme_clusters
end
puts `ps -o rss= -p #{$$}`
end
Before:
26000
42256
59008
75792
92528
109232
125936
142672
159392
176160
After:
9264
9504
9808
10000
10128
10224
10352
10544
10704
10896
---
string.c | 98 +++++++++++++++++++++++++++++++-----------------
test/ruby/test_string.rb | 11 ++++++
2 files changed, 75 insertions(+), 34 deletions(-)
|
|
merge revision(s) 596db9c1f486d6609a4e97d82c8c71b54609fb6f: [Backport #20090]
[Feature #19370] Blocks without anonymous parameters should not
affect
---
parse.y | 4 ++--
test/ruby/test_syntax.rb | 7 +++++++
2 files changed, 9 insertions(+), 2 deletions(-)
|
|
(#9829)
merge revision(s) c5cf4d4e129f64cb69aaf0a829aed068ef1943c4: [Backport #19542]
Improve behavioural consistency of unallocated (zero length)
`IO::Buffer`. (#9532)
This makes the behaviour of IO::Buffer.new(0) and IO::Buffer.new.slice(0, 0) consistent.
Fixes https://bugs.ruby-lang.org/issues/19542 and https://bugs.ruby-lang.org/issues/18805.
---
io_buffer.c | 14 ++++++--------
test/ruby/test_io_buffer.rb | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 8 deletions(-)
|
|
YJIT: Let RubyVM::YJIT.enable respect --yjit-stats
|
|
merge revision(s) 82b57d7bfeefd717c10f7a5a3484aca6b3e708a3: [Backport #20162]
Fix memory leak when duplicating too complex object
[Bug #20162]
Creating a ST table then calling st_replace leaks memory because the
st_replace overwrites the ST table without freeing any of the existing
memory. This commit changes it to use st_copy instead.
For example:
RubyVM::Shape.exhaust_shapes
o = Object.new
o.instance_variable_set(:@a, 0)
10.times do
100_000.times { o.dup }
puts `ps -o rss= -p #{$$}`
end
Before:
23264
33600
42672
52160
61600
71728
81056
90528
100560
109840
After:
14752
14816
15584
15584
15664
15664
15664
15664
15664
15664
---
object.c | 3 +--
test/ruby/test_shapes.rb | 13 +++++++++++++
2 files changed, 14 insertions(+), 2 deletions(-)
|
|
Fix to work match cache with peek next optimization (#9459)
---
regexec.c | 3 ++-
test/ruby/test_regexp.rb | 9 +++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
Fix test case for `test_match_cache_with_peek_optimization` (#9466)
---
test/ruby/test_regexp.rb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
|
|
* Fix GC.measure_total_time regression
Commit 93ac7405b80cc61930d73da04441fa09af1851e1 introduced a regression
where measurements would still be taken after setting
GC.measure_total_time = false.
Fixes [Bug #20157]
* Add test case for GC.measure_total_time
---------
Co-authored-by: Rian McGuire <[email protected]>
|
|
Memory leak when duplicating identhash
[Bug #20145]
Before this commit, both copy_compare_by_id and hash_copy will create a
copy of the ST table, so the ST table created in copy_compare_by_id will
be leaked.
h = { 1 => 2 }.compare_by_identity
10.times do
1_000_000.times do
h.select { false }
end
puts `ps -o rss= -p #{$$}`
end
Before:
110736
204352
300272
395520
460704
476736
542000
604704
682624
770528
After:
15504
16048
16144
16256
16320
16320
16752
16752
16752
16752
---
hash.c | 10 +++++++++-
test/ruby/test_hash.rb | 10 ++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
|
|
Don't create T_MATCH object if /regexp/.match(string) doesn't match
Fixes [Bug #20104]
---
re.c | 9 ++++++---
test/ruby/test_regexp.rb | 12 ++++++++++++
tool/lib/envutil.rb | 8 ++++++++
3 files changed, 26 insertions(+), 3 deletions(-)
|
|
[Backport #20094]"
This reverts commit d4b780e84e9a6b858d0f6c6a44b22da0d2f5835e.
|
|
[Bug #20094] Distinguish `begin` and parentheses
---
compile.c | 1 +
parse.y | 36 +++++++++++++++++++++---------------
test/ruby/test_whileuntil.rb | 18 ++++++++++++++++++
3 files changed, 40 insertions(+), 15 deletions(-)
|
|
Fix [Bug #20083]: correct a cache point size for atomic groups
(#9367)
---
regexec.c | 2 +-
test/ruby/test_regexp.rb | 8 ++++++++
2 files changed, 9 insertions(+), 1 deletion(-)
|
|
Fix Window private file mapping unlink EACCES issue. (#9358)
* Don't return early.
* Add missing `mapping` assignment.
* Make debug logs conditional.
---
io_buffer.c | 18 ++++++++++++------
test/ruby/test_io_buffer.rb | 32 ++++++++++++++------------------
2 files changed, 26 insertions(+), 24 deletions(-)
|
|
|
|
Run this test separately because something seems remained unreleased
on Windows.
|
|
RUBY_FL_PROMOTED is used by the garbage collector to track when an
object becomes promoted to the old generation. rb_obj_setup must not
copy that flag over because then it may become out-of-sync with the age
of the object.
This fixes a bug in Method#clone where the cloned Method object may get
RUBY_FL_PROMOTED incorrectly set.
|
|
|