fix stack overflow when page_size is not 4k
This commit is contained in:
4
deps/oblib/src/common/ob_smart_call.h
vendored
4
deps/oblib/src/common/ob_smart_call.h
vendored
@ -22,7 +22,7 @@ namespace oceanbase
|
|||||||
namespace common
|
namespace common
|
||||||
{
|
{
|
||||||
static constexpr int64_t ALL_STACK_LIMIT = 10L << 20;
|
static constexpr int64_t ALL_STACK_LIMIT = 10L << 20;
|
||||||
static constexpr int64_t STACK_PER_EXTEND = 2L << 20;
|
static constexpr int64_t STACK_PER_EXTEND = (2L << 20) - ACHUNK_PRESERVE_SIZE;
|
||||||
static constexpr int64_t STACK_RESERVED_SIZE = 128L << 10;
|
static constexpr int64_t STACK_RESERVED_SIZE = 128L << 10;
|
||||||
RLOCAL_EXTERN(int64_t, all_stack_size);
|
RLOCAL_EXTERN(int64_t, all_stack_size);
|
||||||
|
|
||||||
@ -36,7 +36,7 @@ inline int call_with_new_stack(void * arg_, int(*func_) (void*))
|
|||||||
size_t ori_stack_size = 0;
|
size_t ori_stack_size = 0;
|
||||||
void *stack_addr = nullptr;
|
void *stack_addr = nullptr;
|
||||||
uint64_t tenant_id = GET_TENANT_ID() == 0 ? 500 : GET_TENANT_ID();
|
uint64_t tenant_id = GET_TENANT_ID() == 0 ? 500 : GET_TENANT_ID();
|
||||||
const int64_t stack_size = lib::ProtectedStackAllocator::adjust_size(STACK_PER_EXTEND);
|
const int64_t stack_size = STACK_PER_EXTEND;
|
||||||
if (OB_FAIL(get_stackattr(ori_stack_addr, ori_stack_size))) {
|
if (OB_FAIL(get_stackattr(ori_stack_addr, ori_stack_size))) {
|
||||||
} else if (FALSE_IT(all_stack_size = 0 == all_stack_size ?
|
} else if (FALSE_IT(all_stack_size = 0 == all_stack_size ?
|
||||||
ori_stack_size : all_stack_size)) {
|
ori_stack_size : all_stack_size)) {
|
||||||
|
|||||||
@ -29,11 +29,6 @@ namespace lib
|
|||||||
ProtectedStackAllocator g_stack_allocer;
|
ProtectedStackAllocator g_stack_allocer;
|
||||||
StackMgr g_stack_mgr;
|
StackMgr g_stack_mgr;
|
||||||
|
|
||||||
ssize_t ProtectedStackAllocator::adjust_size(const ssize_t size)
|
|
||||||
{
|
|
||||||
return size - page_size() * 2 - ACHUNK_PRESERVE_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ssize_t ProtectedStackAllocator::page_size()
|
ssize_t ProtectedStackAllocator::page_size()
|
||||||
{
|
{
|
||||||
return get_page_size();
|
return get_page_size();
|
||||||
|
|||||||
@ -41,7 +41,6 @@ class ProtectedStackAllocator
|
|||||||
public:
|
public:
|
||||||
void *alloc(const uint64_t tenant_id, const ssize_t size);
|
void *alloc(const uint64_t tenant_id, const ssize_t size);
|
||||||
void dealloc(void *ptr);
|
void dealloc(void *ptr);
|
||||||
static ssize_t adjust_size(const ssize_t size);
|
|
||||||
static ObStackHeader *stack_header(void *ptr);
|
static ObStackHeader *stack_header(void *ptr);
|
||||||
static ssize_t page_size();
|
static ssize_t page_size();
|
||||||
private:
|
private:
|
||||||
|
|||||||
2
deps/oblib/src/lib/thread/threads.cpp
vendored
2
deps/oblib/src/lib/thread/threads.cpp
vendored
@ -23,7 +23,7 @@
|
|||||||
using namespace oceanbase::lib;
|
using namespace oceanbase::lib;
|
||||||
using namespace oceanbase::common;
|
using namespace oceanbase::common;
|
||||||
|
|
||||||
int64_t global_thread_stack_size = ProtectedStackAllocator::adjust_size(1L << 19) - SIG_STACK_SIZE;
|
int64_t global_thread_stack_size = (1L << 19) - SIG_STACK_SIZE - ACHUNK_PRESERVE_SIZE;
|
||||||
thread_local uint64_t ThreadPool::thread_idx_ = 0;
|
thread_local uint64_t ThreadPool::thread_idx_ = 0;
|
||||||
|
|
||||||
// 获取线程局部的租户上下文,为线程池启动时检查使用
|
// 获取线程局部的租户上下文,为线程池启动时检查使用
|
||||||
|
|||||||
@ -110,7 +110,7 @@ TEST(sc, usability)
|
|||||||
void *cur_stack_addr = nullptr;
|
void *cur_stack_addr = nullptr;
|
||||||
size_t cur_stack_size = 0;
|
size_t cur_stack_size = 0;
|
||||||
int stack_change_cnt = 0;
|
int stack_change_cnt = 0;
|
||||||
#define STACK_PER_EXTEND_SIZE lib::ProtectedStackAllocator::adjust_size(STACK_PER_EXTEND)
|
#define STACK_PER_EXTEND_SIZE STACK_PER_EXTEND
|
||||||
const int64_t s_size = STACK_PER_EXTEND_SIZE;
|
const int64_t s_size = STACK_PER_EXTEND_SIZE;
|
||||||
int test(int &i, int once_invoke_hold)
|
int test(int &i, int once_invoke_hold)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1645,7 +1645,7 @@ int ObServer::init_pre_setting()
|
|||||||
if (OB_SUCC(ret)) {
|
if (OB_SUCC(ret)) {
|
||||||
const int64_t stack_size = std::max(1L << 19, static_cast<int64_t>(GCONF.stack_size));
|
const int64_t stack_size = std::max(1L << 19, static_cast<int64_t>(GCONF.stack_size));
|
||||||
LOG_INFO("set stack_size", K(stack_size));
|
LOG_INFO("set stack_size", K(stack_size));
|
||||||
global_thread_stack_size = lib::ProtectedStackAllocator::adjust_size(stack_size) - SIG_STACK_SIZE;
|
global_thread_stack_size = stack_size - SIG_STACK_SIZE - ACHUNK_PRESERVE_SIZE;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user