changeset 242:f1096afde036

Bug 3421: Override functions might crash on Fedora 26 Reviewed-by: ykubota https://github.com/HeapStats/heapstats/pull/110
author Yasumasa Suenaga <yasuenag@gmail.com>
date Fri, 14 Jul 2017 12:18:45 +0900
parents 5ee1c4138b61
children be9892e921b3
files ChangeLog agent/src/heapstats-engines/arch/x86/overrideFunc.amd64.S
diffstat 2 files changed, 12 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Jul 11 18:15:01 2017 +0900
+++ b/ChangeLog	Fri Jul 14 12:18:45 2017 +0900
@@ -1,3 +1,7 @@
+2017-07-14 Yasumasa Suenaga <yasuenag@gmail.com>
+
+	* Bug 3421: Override functions might crash on Fedora 26
+
 2017-07-11 Yasumasa Suenaga <yasuenag@gmail.com>
 
 	* Bug 3419: Provide FXAnalyzer RPM package for Fedora
--- a/agent/src/heapstats-engines/arch/x86/overrideFunc.amd64.S	Tue Jul 11 18:15:01 2017 +0900
+++ b/agent/src/heapstats-engines/arch/x86/overrideFunc.amd64.S	Fri Jul 14 12:18:45 2017 +0900
@@ -3,7 +3,7 @@
  * \brief This file is used to override JVM inner function for AMD64.<br>
  *        The function defined this file, used with v-table hook.<br>
  *        So in this file, all function is written by only assembler and macro.
- * Copyright (C) 2014-2015 Yasumasa Suenaga
+ * Copyright (C) 2014-2017 Yasumasa Suenaga
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -58,13 +58,19 @@
   mov collectedHeap@GOTPCREL(%rip), %rdi;   \
   mov (%rdi), %rdi;                         \
   mov oop_ofs(%rsp), %rsi;                  \
+  push %rbp;                                \
+  mov %rsp, %rbp;                           \
   call *(%r11);                             \
+  pop %rbp;                                 \
   test %al, %al;                            
 
 #define DO_JMP_TO_CALLBACK(header, ary_idx, oop_ofs) \
   mov oop_ofs(%rsp), %rdi;                                  \
   mov header##_enter_hook_##ary_idx##@GOTPCREL(%rip), %r11; \
-  call *(%r11);
+  push %rbp;                                                \
+  mov %rsp, %rbp;                                           \
+  call *(%r11);                                             \
+  pop %rbp;
 
 #define OVERRIDE_FUNC_DEFINE(header, ary_idx) \
 .global header##_override_func_##ary_idx ;                     \