MCPcopy Create free account
hub / github.com/catboost/catboost / TEST

Function TEST

library/cpp/coroutine/engine/stack/ut/stack_guards_ut.cpp:71–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69 }
70
71 TEST(StackGuardTest, CanaryGuardTestOverflow) {
72 const auto& guard = GetGuard<TCanaryGuard>();
73
74 char *rawPtr, *alignedPtr = nullptr;
75 constexpr size_t sizeInPages = 4;
76 ASSERT_TRUE(GetAlignedMemory(sizeInPages + 1, rawPtr, alignedPtr));
77 guard.Protect(alignedPtr, PageSize, false); // set previous guard
78 alignedPtr += PageSize; // leave first page for previous guard
79 guard.Protect(alignedPtr, sizeInPages * PageSize, true);
80
81 EXPECT_TRUE(guard.CheckOverflow(alignedPtr));
82 EXPECT_TRUE(guard.CheckOverride(alignedPtr, sizeInPages * PageSize));
83
84 // Overwrite previous guard
85 *(alignedPtr - 1) = 42;
86
87 EXPECT_FALSE(guard.CheckOverflow(alignedPtr));
88
89 free(rawPtr);
90 }
91
92 TEST(StackGuardTest, CanaryGuardTestOverride) {
93 const auto& guard = GetGuard<TCanaryGuard>();

Callers

nothing calls this directly

Calls 6

GetAlignedMemoryFunction · 0.85
freeFunction · 0.50
ProtectMethod · 0.45
CheckOverflowMethod · 0.45
CheckOverrideMethod · 0.45
RemoveProtectionMethod · 0.45

Tested by

no test coverage detected