# HG changeset patch # User Yasumasa Suenaga # Date 1500346947 -32400 # Node ID ec74982008b58c67d5a2c22be9426fbcbcedc6d7 # Parent 31e2f34f62d526ef64d90396700d19c154109394 Bug 3421: Override functions might crash on Fedora 26 Reviewed-by: ykubota https://github.com/HeapStats/heapstats/pull/110 diff -r 31e2f34f62d5 -r ec74982008b5 agent/ChangeLog --- a/agent/ChangeLog Wed Jul 05 14:02:51 2017 +0900 +++ b/agent/ChangeLog Tue Jul 18 12:02:27 2017 +0900 @@ -1,3 +1,7 @@ +2017-07-18 Yasumasa Suenaga + + * Bug 3421: Override functions might crash on Fedora 26 + 2017-07-05 KUBOTA Yuji * Bump to 1.0.8 diff -r 31e2f34f62d5 -r ec74982008b5 agent/src/overrideFunc.S --- a/agent/src/overrideFunc.S Wed Jul 05 14:02:51 2017 +0900 +++ b/agent/src/overrideFunc.S Tue Jul 18 12:02:27 2017 +0900 @@ -1,7 +1,7 @@ /*! * \file overrideFunc.S * \brief This file is used to override JVM inner function.
- * Copyright (C) 2011-2015 Nippon Telegraph and Telephone Corporation + * Copyright (C) 2011-2017 Nippon Telegraph and Telephone Corporation * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -25,7 +25,9 @@ #define OVERRIDE_FUNC_DEFINE(header, ary_idx) \ .global header##_override_func_##ary_idx ; \ .type header##_override_func_##ary_idx, @function; \ - header##_override_func_##ary_idx: ; + header##_override_func_##ary_idx: ; \ + push %rbp; \ + mov %rsp, %rbp; #if defined(__amd64__) @@ -163,6 +165,8 @@ #define OVERRIDE_CALLBACK_DEFINE(header, ary_idx, func) \ OVERRIDE_FUNC_DEFINE(header, ary_idx) \ + /* Stack alignment */ \ + sub $8, %rsp; \ \ /* Get all override info. */ ; \ GET_ALL_FUNC_ADDR(header, ary_idx) \ @@ -439,6 +443,10 @@ #if defined(__amd64__) pop %r11 DO_LOAD_REG + /* Restore stack pointer */ + mov %rbp, %rsp; + /* Restore base pointer */ + pop %rbp; jmp *%r11 #elif defined(__i386__) addl $0x4, %esp @@ -450,6 +458,10 @@ .RETURN_CALLER_FUNC: #if defined(__amd64__) + /* Restore stack pointer */ + mov %rbp, %rsp; + /* Restore base pointer */ + pop %rbp; /* Return caller. Return address exists on top of stack. */ /* We need to pop return address from stack. */ pop %r11