Project

General

Profile

Bug #17539

Guard callinfo during compilation (backport)

Added by tenderlovemaking (Aaron Patterson) about 2 months ago. Updated about 1 month ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:102077]

Description

Hi,

Please backport efcdf68e6443ab70fbff1703b9dabbfc5090df31 to ruby_3_0. We're seeing segvs, and efcdf68e6443ab70fbff1703b9dabbfc5090df31 fixes it.

Thanks!

Updated by tenderlovemaking (Aaron Patterson) about 2 months ago

Also please add 5e26619660f20272a53c7f839dde36cce034bb35 (it fixes a write barrier issue)

Thanks!

Updated by naruse (Yui NARUSE) about 1 month ago

  • Backport changed from 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: REQUIRED to 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: DONE

ruby_3_0 74f90b46a9f21e8ef6e01bebad9dc00f420f8cec merged revision(s) efcdf68e6443ab70fbff1703b9dabbfc5090df31,5e26619660f20272a53c7f839dde36cce034bb35.

#3

Updated by naruse (Yui NARUSE) about 1 month ago

  • Status changed from Open to Closed

Applied in changeset git|74f90b46a9f21e8ef6e01bebad9dc00f420f8cec.


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(+)

Also available in: Atom PDF