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

ruby-changes:50506

From: nagachika <ko1@a...>
Date: Sat, 3 Mar 2018 11:39:52 +0900 (JST)
Subject: [ruby-changes:50506] nagachika:r62640 (ruby_2_4): merge revision(s) 59893, 59922: [Backport #13895]

nagachika	2018-03-03 11:39:47 +0900 (Sat, 03 Mar 2018)

  New Revision: 62640

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62640

  Log:
    merge revision(s) 59893,59922: [Backport #13895]
    
    fix the case High Sierra's mincore(2) may return -128 [Bug #13895]
    
    Fix typos [ci skip]

  Modified directories:
    branches/ruby_2_4/
  Modified files:
    branches/ruby_2_4/version.h
    branches/ruby_2_4/vm_dump.c
Index: ruby_2_4/vm_dump.c
===================================================================
--- ruby_2_4/vm_dump.c	(revision 62639)
+++ ruby_2_4/vm_dump.c	(revision 62640)
@@ -455,7 +455,7 @@ darwin_sigtramp: https://github.com/ruby/ruby/blob/trunk/ruby_2_4/vm_dump.c#L455
 	ucontext_t *uctx;
 	char vec[1];
 	int r;
-	/* get _sigtramp's ucontext_t and set values to cursor
+	/* get previous frame information from %rbx at _sigtramp and set values to cursor
 	 * http://www.opensource.apple.com/source/Libc/Libc-825.25/i386/sys/_sigtramp.s
 	 * http://www.opensource.apple.com/source/libunwind/libunwind-35.1/src/unw_getcontext.s
 	 */
@@ -478,8 +478,35 @@ darwin_sigtramp: https://github.com/ruby/ruby/blob/trunk/ruby_2_4/vm_dump.c#L478
 	unw_set_reg(&cursor, UNW_X86_64_R14, uctx->uc_mcontext->__ss.__r14);
 	unw_set_reg(&cursor, UNW_X86_64_R15, uctx->uc_mcontext->__ss.__r15);
 	ip = uctx->uc_mcontext->__ss.__rip;
+
+	/* There're 4 cases for SEGV:
+	 * (1) called invalid address
+	 * (2) read or write invalid address
+	 * (3) received signal
+	 *
+	 * Detail:
+	 * (1) called invalid address
+	 * In this case, saved ip is invalid address.
+	 * It needs to just save the address for the information,
+	 * skip the frame, and restore the frame calling the
+	 * invalid address from %rsp.
+	 * The problem is how to check whether the ip is valid or not.
+	 * This code uses mincore(2) and assume the address's page is
+	 * incore/referenced or not reflects the problem.
+	 * Note that High Sierra's mincore(2) may return -128.
+	 * (2) read or write invalid address
+	 * saved ip is valid. just restart backtracing.
+	 * (3) received signal in user space
+	 * Same as (2).
+	 * (4) received signal in kernel
+	 * In this case saved ip points just after syscall, but registers are
+	 * already overwritten by kernel. To fix register consistency,
+	 * skip libc's kernel wrapper.
+	 * To detect this case, just previous two bytes of ip is "\x0f\x05",
+	 * syscall instruction of x86_64.
+	 */
 	r = mincore((const void *)ip, 1, vec);
-	if (r || !vec[0] || memcmp((const char *)ip-2, "\x0f\x05", 2) == 0) {
+	if (r || vec[0] <= 0 || memcmp((const char *)ip-2, "\x0f\x05", 2) == 0) {
 	    /* if segv is caused by invalid call or signal received in syscall */
 	    /* the frame is invalid; skip */
 	    trace[n++] = (void *)ip;
Index: ruby_2_4/version.h
===================================================================
--- ruby_2_4/version.h	(revision 62639)
+++ ruby_2_4/version.h	(revision 62640)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1
 #define RUBY_VERSION "2.4.4"
 #define RUBY_RELEASE_DATE "2018-03-03"
-#define RUBY_PATCHLEVEL 244
+#define RUBY_PATCHLEVEL 245
 
 #define RUBY_RELEASE_YEAR 2018
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_4
===================================================================
--- ruby_2_4	(revision 62639)
+++ ruby_2_4	(revision 62640)

Property changes on: ruby_2_4
___________________________________________________________________
Modified: svn:mergeinfo
## -0,0 +0,1 ##
   Merged /trunk:r59893,59922

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

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