libfoedus-core
FOEDUS Core Library
|
A 4kb dummy data placed between separate memory regions so that we can check if/where a bogus memory access happens. More...
A 4kb dummy data placed between separate memory regions so that we can check if/where a bogus memory access happens.
As a middleware, we often allocate a large chunk of memory and internally split it into smaller data regions. While it reduces overheads, that means a lack of memory boundary check. Instead, we place this dummy block to achieve it. When we shut down the system, we check if there happened any unexpected overrun between memory regions. In addition, we also use mprotect() to prohibit accesses to these dummy blocks, which would immediately fire up SIGSEGV for bogus access, making debugging easier.
Definition at line 56 of file protected_boundary.hpp.
#include <protected_boundary.hpp>
Public Types | |
enum | Constants { kByteSize = 1 << 12, kMaxBoundaryNameLength = 128, kWordCount = (kByteSize - kMaxBoundaryNameLength) / 8 } |
Public Member Functions | |
ErrorCode | acquire_protect () |
Puts a strict access prohibition via mprotect(). More... | |
ErrorCode | release_protect () |
Removes all access restrictions via mprotect(). More... | |
void | reset (const std::string &boundary_name) |
Fills the block with magic words. More... | |
void | assert_boundary () const |
Called at shutdown to check whether these boundaries were not accessed. More... | |
std::string | get_boundary_name () const |
Public Attributes | |
char | boundary_name_ [kMaxBoundaryNameLength] |
uint64_t | data_ [kWordCount] |
Enumerator | |
---|---|
kByteSize | |
kMaxBoundaryNameLength | |
kWordCount |
Definition at line 57 of file protected_boundary.hpp.
ErrorCode foedus::assorted::ProtectedBoundary::acquire_protect | ( | ) |
Puts a strict access prohibition via mprotect().
Definition at line 25 of file protected_boundary.cpp.
References foedus::kErrorCodeOk, and foedus::kErrorCodeOsMProtectFailed.
Referenced by foedus::memory::PagePoolPimpl::initialize_once().
|
inline |
Called at shutdown to check whether these boundaries were not accessed.
Definition at line 103 of file protected_boundary.hpp.
References ASSERT_ND, and kWordCount.
Referenced by foedus::soc::SharedMemoryRepo::deallocate_shared_memories(), and foedus::memory::PagePoolPimpl::uninitialize_once().
|
inline |
Definition at line 109 of file protected_boundary.hpp.
References ASSERT_ND, and kMaxBoundaryNameLength.
Referenced by foedus::memory::PagePoolPimpl::uninitialize_once().
ErrorCode foedus::assorted::ProtectedBoundary::release_protect | ( | ) |
Removes all access restrictions via mprotect().
Definition at line 33 of file protected_boundary.cpp.
References foedus::kErrorCodeOk, and foedus::kErrorCodeOsMProtectFailed.
Referenced by foedus::soc::SharedMemoryRepo::deallocate_shared_memories(), and foedus::memory::PagePoolPimpl::uninitialize_once().
|
inline |
Fills the block with magic words.
Definition at line 88 of file protected_boundary.hpp.
References kMaxBoundaryNameLength, foedus::assorted::kProtectedBoundaryMagicWord, and kWordCount.
Referenced by foedus::memory::PagePoolPimpl::initialize_once().
char foedus::assorted::ProtectedBoundary::boundary_name_[kMaxBoundaryNameLength] |
Definition at line 63 of file protected_boundary.hpp.
uint64_t foedus::assorted::ProtectedBoundary::data_[kWordCount] |
Definition at line 64 of file protected_boundary.hpp.