# HG changeset patch # User zgu # Date 1530563289 14400 # Node ID b9c7eb8d89728dd1f710796db27a2c38898aef9f # Parent 0221f6a72e4ba8ffae84ffc34d066e09a90beb8f 8205965: SIGSEGV on write to NativeCallStack::EMPTY_STACK Summary: Made EMPTY_STACK non-const, so it will not be placed in read-only BSS section. Reviewed-by: stuefe, martin diff -r 0221f6a72e4b -r b9c7eb8d8972 src/hotspot/share/services/mallocSiteTable.hpp --- a/src/hotspot/share/services/mallocSiteTable.hpp Mon Jul 02 00:55:24 2018 -0700 +++ b/src/hotspot/share/services/mallocSiteTable.hpp Mon Jul 02 16:28:09 2018 -0400 @@ -42,7 +42,7 @@ public: MallocSite() : - AllocationSite(NativeCallStack::EMPTY_STACK), _flags(mtNone) {} + AllocationSite(NativeCallStack::empty_stack()), _flags(mtNone) {} MallocSite(const NativeCallStack& stack, MEMFLAGS flags) : AllocationSite(stack), _flags(flags) {} diff -r 0221f6a72e4b -r b9c7eb8d8972 src/hotspot/share/services/memTracker.hpp --- a/src/hotspot/share/services/memTracker.hpp Mon Jul 02 00:55:24 2018 -0700 +++ b/src/hotspot/share/services/memTracker.hpp Mon Jul 02 16:28:09 2018 -0400 @@ -31,8 +31,8 @@ #if !INCLUDE_NMT -#define CURRENT_PC NativeCallStack::EMPTY_STACK -#define CALLER_PC NativeCallStack::EMPTY_STACK +#define CURRENT_PC NativeCallStack::empty_stack() +#define CALLER_PC NativeCallStack::empty_stack() class Tracker : public StackObj { public: @@ -86,9 +86,9 @@ extern volatile bool NMT_stack_walkable; #define CURRENT_PC ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ? \ - NativeCallStack(0, true) : NativeCallStack::EMPTY_STACK) + NativeCallStack(0, true) : NativeCallStack::empty_stack()) #define CALLER_PC ((MemTracker::tracking_level() == NMT_detail && NMT_stack_walkable) ? \ - NativeCallStack(1, true) : NativeCallStack::EMPTY_STACK) + NativeCallStack(1, true) : NativeCallStack::empty_stack()) class MemBaseline; class Mutex; diff -r 0221f6a72e4b -r b9c7eb8d8972 src/hotspot/share/services/virtualMemoryTracker.hpp --- a/src/hotspot/share/services/virtualMemoryTracker.hpp Mon Jul 02 00:55:24 2018 -0700 +++ b/src/hotspot/share/services/virtualMemoryTracker.hpp Mon Jul 02 16:28:09 2018 -0400 @@ -302,7 +302,7 @@ ReservedMemoryRegion(address base, size_t size) : - VirtualMemoryRegion(base, size), _stack(NativeCallStack::EMPTY_STACK), _flag(mtNone) { } + VirtualMemoryRegion(base, size), _stack(NativeCallStack::empty_stack()), _flag(mtNone) { } // Copy constructor ReservedMemoryRegion(const ReservedMemoryRegion& rr) : diff -r 0221f6a72e4b -r b9c7eb8d8972 src/hotspot/share/utilities/nativeCallStack.cpp --- a/src/hotspot/share/utilities/nativeCallStack.cpp Mon Jul 02 00:55:24 2018 -0700 +++ b/src/hotspot/share/utilities/nativeCallStack.cpp Mon Jul 02 16:28:09 2018 -0400 @@ -28,7 +28,7 @@ #include "utilities/globalDefinitions.hpp" #include "utilities/nativeCallStack.hpp" -const NativeCallStack NativeCallStack::EMPTY_STACK(0, false); +NativeCallStack NativeCallStack::EMPTY_STACK(0, false); NativeCallStack::NativeCallStack(int toSkip, bool fillStack) : _hash_value(0) { @@ -126,4 +126,3 @@ } } } - diff -r 0221f6a72e4b -r b9c7eb8d8972 src/hotspot/share/utilities/nativeCallStack.hpp --- a/src/hotspot/share/utilities/nativeCallStack.hpp Mon Jul 02 00:55:24 2018 -0700 +++ b/src/hotspot/share/utilities/nativeCallStack.hpp Mon Jul 02 16:28:09 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,18 +51,23 @@ * 2. The class is strict stack object, no heap or virtual memory can be allocated * from it. */ +class MemTracker; + class NativeCallStack : public StackObj { - public: - static const NativeCallStack EMPTY_STACK; + friend class MemTracker; - private: +private: address _stack[NMT_TrackingStackDepth]; unsigned int _hash_value; - public: + static NativeCallStack EMPTY_STACK; +public: NativeCallStack(int toSkip = 0, bool fillStack = false); NativeCallStack(address* pc, int frameCount); + static inline const NativeCallStack& empty_stack() { + return EMPTY_STACK; + } // if it is an empty stack inline bool is_empty() const {