googletest icon indicating copy to clipboard operation
googletest copied to clipboard

gtest is handling _chkstk improperly.

Open ZehMatt opened this issue 6 years ago • 1 comments

_chkstk will probe the stack pages for the given size and eventually allocates more space if it exceeds 4k (32 bit) or 8k (64 bit). This is done by exceptions and gtest seems to swallow them rather than passing them over so you will end up having test failures.

constexpr size_t BufferLength = 1024 * 1024 * 10;

TEST(ChkstkFail, all)
{
    uint8_t StackData[BufferLength];

    StackData[BufferLength - 1] = 0xFF;
    ASSERT_EQ(StackData[BufferLength - 1], 0xFF);

    SUCCEED();
}

The above snippet will throw following exception.

Exception thrown at 0x00007FF6DFBBBC18 in tests.exe: 0xC00000FD: Stack overflow (parameters: 0x0000000000000001, 0x00000093E4803000).

The given snippet will function normally when not using the gtest environment.

ZehMatt avatar Mar 02 '19 00:03 ZehMatt

Meet the same issue, any progress/solution/reason?

chen-assert avatar Aug 09 '22 08:08 chen-assert