[前][次][番号順一覧][スレッド一覧]

ruby-changes:61607

From: Jeremy <ko1@a...>
Date: Tue, 9 Jun 2020 03:11:59 +0900 (JST)
Subject: [ruby-changes:61607] 0ba27259d3 (master): Fix crashes in the peephole optimizer on OpenBSD/sparc64

https://git.ruby-lang.org/ruby.git/commit/?id=0ba27259d3

From 0ba27259d390e902139c0e2e94b9d18ef227748e Mon Sep 17 00:00:00 2001
From: Jeremy Evans <code@j...>
Date: Thu, 12 Mar 2020 15:34:45 -0700
Subject: Fix crashes in the peephole optimizer on OpenBSD/sparc64

These crashes are due to alignment issues, casting ADJUST to INSN
and then accessing after the end of the ADJUST.  These patches
come from Stefan Sperling <stsp@a...>, who reported the
issue.

diff --git a/compile.c b/compile.c
index 24d2561..5a7a088 100644
--- a/compile.c
+++ b/compile.c
@@ -2776,7 +2776,8 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal https://github.com/ruby/ruby/blob/trunk/compile.c#L2776
 	    ELEM_REMOVE(&iobj->link);
 	    return COMPILE_OK;
 	}
-	else if (iobj != diobj && IS_INSN_ID(diobj, jump) &&
+        else if (iobj != diobj && IS_INSN(&diobj->link) &&
+                 IS_INSN_ID(diobj, jump) &&
 		 OPERAND_AT(iobj, 0) != OPERAND_AT(diobj, 0)) {
 	    /*
 	     *  useless jump elimination:
@@ -2954,7 +2955,7 @@ iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcal https://github.com/ruby/ruby/blob/trunk/compile.c#L2955
             }
 
             for (;;) {
-                if (IS_INSN_ID(nobj, jump)) {
+                if (IS_INSN(&nobj->link) && IS_INSN_ID(nobj, jump)) {
                     replace_destination(iobj, nobj);
                 }
                 else if (prev_dup && IS_INSN_ID(nobj, dup) &&
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]