Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
56 lines (47 loc) · 1.74 KB

File metadata and controls

56 lines (47 loc) · 1.74 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "TestHelpers.h"
using namespace hermes::hbc;
using namespace hermes::vm;
namespace {
// Count the number of native stack frames we can make before it reports
// overflow. Also verify that our stack descends down.
static unsigned makeFramesUntilOverflow(
Runtime *runtime,
ScopedNativeCallFrame *prev) {
ScopedNativeCallFrame frame{
runtime, 0, nullptr, false, HermesValue::encodeUndefinedValue()};
if (frame.overflowed())
return 0;
EXPECT_TRUE(!prev || (*prev)->ptr() > frame->ptr());
return 1 + makeFramesUntilOverflow(runtime, &frame);
}
using NativeFrameTest = RuntimeTestFixture;
TEST_F(NativeFrameTest, OverflowTest) {
unsigned maxDepth = makeFramesUntilOverflow(runtime, nullptr);
// Save into a local variable in order to avoid linker errors when passed
// to gtest.
auto expectedMaxDepth = Runtime::MAX_NATIVE_CALL_FRAME_DEPTH;
EXPECT_EQ(maxDepth, expectedMaxDepth);
}
#if HERMES_SLOW_DEBUG
TEST_F(NativeFrameTest, PoisonedStackTest) {
// Verify that stack frames are poisoned.
ScopedNativeCallFrame frame{
runtime, 0, nullptr, false, HermesValue::encodeUndefinedValue()};
ASSERT_FALSE(frame.overflowed());
// We should not die after this because there were no arguments.
runtime->collect("test");
// Now make a frame with arguments.
ScopedNativeCallFrame frame2{
runtime, 1, nullptr, false, HermesValue::encodeUndefinedValue()};
ASSERT_FALSE(frame2.overflowed());
// The frame should be poisoned; ensure we die after a GC.
EXPECT_DEATH(runtime->collect("test"), "Invalid");
}
#endif
} // namespace
Morty Proxy This is a proxified and sanitized view of the page, visit original site.