Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YJIT: Avoid BorrowError on GC.compact #7164

Merged
merged 1 commit into from Jan 20, 2023

Conversation

k0kubun
Copy link
Member

@k0kubun k0kubun commented Jan 20, 2023

Follows up #7151.

On rb_yjit_iseq_update_references for GC.compact, a cyclic block reference could cause BorrowError like:

thread '<unnamed>' panicked at 'already mutably borrowed: BorrowError', src/core.rs:504:16
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/std/src/panicking.rs:575:5
     1: core::panicking::panic_fmt
               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/panicking.rs:65:14
     2: core::result::unwrap_failed
               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/result.rs:1791:5
     3: core::result::Result<T,E>::expect
               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/result.rs:1070:23
     4: core::cell::RefCell<T>::borrow
               at /rustc/90743e7298aca107ddaa0c202a4d3604e29bfeb6/library/core/src/cell.rs:865:9
     5: yjit::core::BlockRef::borrow
               at /home/runner/work/ruby/ruby/src/yjit/src/core.rs:504:9
     6: yjit::core::BranchTarget::get_blockid
               at /home/runner/work/ruby/ruby/src/yjit/src/core.rs:358:46
     7: rb_yjit_iseq_update_references
               at /home/runner/work/ruby/ruby/src/yjit/src/core.rs:763:61
     8: rb_iseq_mark_and_update
               at ./../src/iseq.c:363:13
     9: gc_ref_update
               at ./../src/gc.c:10765:17
    10: gc_update_references
               at ./../src/gc.c:10799:13
    11: gc_compact_finish
               at ./../src/gc.c:5536:5
    12: gc_sweep_compact
               at ./../src/gc.c:8672:5
    13: gc_sweep
               at ./../src/gc.c:6196:9
    14: gc_marks
               at ./../src/gc.c:8735:9
    15: gc_start
               at ./../src/gc.c:9566:9
    16: garbage_collect
               at ./../src/gc.c:[94](https://github.com/ruby/ruby/actions/runs/3966171876/jobs/6798595153#step:19:99)47:15
    17: gc_start_internal
               at ./../src/gc.c:[98](https://github.com/ruby/ruby/actions/runs/3966171876/jobs/6798595153#step:19:103)67:5
    18: gc_verify_compaction_references
               at ./../src/gc.c:10[99](https://github.com/ruby/ruby/actions/runs/3966171876/jobs/6798595153#step:19:104)2:5
    19: <unknown>
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
  fatal runtime error: failed to initiate panic, error 5
  make: *** [uncommon.mk:850: yes-test-all] Aborted (core dumped)

https://github.com/ruby/ruby/actions/runs/3966171876/jobs/6796691883#step:19:141

@matzbot matzbot requested a review from a team January 20, 2023 19:22
@k0kubun k0kubun merged commit 887d216 into ruby:master Jan 20, 2023
@k0kubun k0kubun deleted the yjit-double-borrow branch January 20, 2023 21:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants