提交 d4c26325 编写于 作者: Z zgu

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
Contributed-by: zhaixiang@loongson.cn
上级 1875639a
/*
* Copyright (c) 2014, 2017, 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
......@@ -42,7 +42,7 @@ class MallocSite : public AllocationSite<MemoryCounter> {
public:
MallocSite() :
AllocationSite<MemoryCounter>(NativeCallStack::EMPTY_STACK), _flags(mtNone) {}
AllocationSite<MemoryCounter>(NativeCallStack::empty_stack()), _flags(mtNone) {}
MallocSite(const NativeCallStack& stack, MEMFLAGS flags) :
AllocationSite<MemoryCounter>(stack), _flags(flags) {}
......
/*
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
......@@ -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:
......@@ -83,9 +83,9 @@ class MemTracker : AllStatic {
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;
......
......@@ -167,7 +167,7 @@ bool ReservedMemoryRegion::remove_uncommitted_region(address addr, size_t sz) {
// higher part
address high_base = addr + sz;
size_t high_size = top - high_base;
CommittedMemoryRegion high_rgn(high_base, high_size, NativeCallStack::EMPTY_STACK);
CommittedMemoryRegion high_rgn(high_base, high_size, NativeCallStack::empty_stack());
return add_committed_region(high_rgn);
} else {
return false;
......
/*
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
......@@ -305,7 +305,7 @@ class ReservedMemoryRegion : public VirtualMemoryRegion {
ReservedMemoryRegion(address base, size_t size) :
VirtualMemoryRegion(base, size), _stack(NativeCallStack::EMPTY_STACK), _flag(mtNone),
VirtualMemoryRegion(base, size), _stack(NativeCallStack::empty_stack()), _flag(mtNone),
_all_committed(false) { }
// Copy constructor
......
/*
* 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
......@@ -27,7 +27,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) {
......@@ -114,4 +114,3 @@ void NativeCallStack::print_on(outputStream* out, int indent) const {
}
}
}
/*
* 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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册