mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 16:50:48 +00:00
Add a guard page for alternative signal handling stack
This commit is contained in:
parent
4dcbf3a5c5
commit
12eadc2b5e
@ -7,6 +7,7 @@
|
||||
|
||||
#include <Poco/Logger.h>
|
||||
#include <common/getThreadId.h>
|
||||
#include <common/getPageSize.h>
|
||||
|
||||
#include <csignal>
|
||||
|
||||
@ -43,10 +44,15 @@ namespace
|
||||
struct ThreadStack
|
||||
{
|
||||
ThreadStack()
|
||||
: data(aligned_alloc(4096, size))
|
||||
{}
|
||||
: data(aligned_alloc(getPageSize(), size))
|
||||
{
|
||||
/// Add a guard page
|
||||
/// (and since the stack grows downward, we need to protect the first page).
|
||||
mprotect(data, getPageSize(), PROT_NONE);
|
||||
}
|
||||
~ThreadStack()
|
||||
{
|
||||
mprotect(data, getPageSize(), PROT_WRITE|PROT_READ);
|
||||
free(data);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user