diff options
author | NARUSE, Yui <naruse@airemix.jp> | 2021-02-01 21:42:11 +0900 |
---|---|---|
committer | NARUSE, Yui <naruse@airemix.jp> | 2021-02-01 21:42:11 +0900 |
commit | 74f90b46a9f21e8ef6e01bebad9dc00f420f8cec (patch) | |
tree | ecf34fd502c5d7a2c30168c06a0570a76898c11a /test/ruby/test_gc.rb | |
parent | d1fb0a39537d4536869921383ee2a223cc6dfac9 (diff) |
merge revision(s) efcdf68e6443ab70fbff1703b9dabbfc5090df31,5e26619660f20272a53c7f839dde36cce034bb35: [Backport #17539]
Guard callinfo
Callinfo was being written in to an array and the GC would not see the
reference on the stack. `new_insn_send` creates a new callinfo object,
then it calls `new_insn_core`. `new_insn_core` allocates a new INSN
linked list item, which can end up calling `xmalloc` which will trigger
a GC:
https://github.com/ruby/ruby/blob/70cd351c7c71c48ee18d7c01e851a89614086f8f/compile.c#L968-L969
Since the callinfo object isn't on the stack, the GC won't see it, and
it can get collected. This patch just refactors `new_insn_send` to keep
the object on the stack
Co-authored-by: John Hawthorn <john@hawthorn.email>
---
compile.c | 7 +++++--
test/ruby/test_gc.rb | 10 ++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
Fix WB for callinfo
The WB for callinfo needs to be executed *after* the reference is
written. Otherwise we get a WB miss.
---
compile.c | 1 +
1 file changed, 1 insertion(+)
Diffstat (limited to 'test/ruby/test_gc.rb')
-rw-r--r-- | test/ruby/test_gc.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index daa8b5c37a..1f75a34cac 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -175,6 +175,16 @@ class TestGc < Test::Unit::TestCase assert_raise_with_message(ArgumentError, /\u{30eb 30d3 30fc}/) {GC.latest_gc_info(:"\u{30eb 30d3 30fc}")} end + def test_stress_compile_send + assert_in_out_err(%w[--disable-gems], <<-EOS, [], [], "") + GC.stress = true + begin + eval("A::B.c(1, 1, d: 234)") + rescue + end + EOS + end + def test_singleton_method assert_in_out_err(%w[--disable-gems], <<-EOS, [], [], "[ruby-dev:42832]") GC.stress = true |