Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack size causes catch platform to throw exception #547

Closed
kerdemdemir opened this issue Dec 6, 2015 · 5 comments
Closed

Stack size causes catch platform to throw exception #547

kerdemdemir opened this issue Dec 6, 2015 · 5 comments

Comments

@kerdemdemir
Copy link

kerdemdemir commented Dec 6, 2015

I have a class like:

struct Reader
{

static constexpr size_t MAX_FILE_SIZE = 10000;
using ReaderIter = std::array< double , MAX_FILE_SIZE >::iterator;
using ReaderView = ranges::counted_view< ReaderIter, int >;

std::array<double, MAX_FILE_SIZE> rawData;
size_t fileSize;

ReaderView getView()
{
    return ranges::counted_view< ReaderIter, int >( rawData.begin(), fileSize);
}


ReaderView
openWavFile(std::string fileName)
{
    .... Long logic removed to ease understanding
    return getView();
}

};

If I write a test like:

TEST_CASE( "SoundFileRead ", "[Reader]" ) {

Reader reader1;

auto readView = reader1.openWavFile("D:/speakerWavs/test/f1rsenae.wav");
auto readerChunks = readView | ranges::view::chunk(256);
auto frontChunkFirst = readerChunks.front();


auto readView2 = reader1.openWavFile("D:/speakerWavs/test/f1rsenae.wav");
auto readerChunks2 = readView | ranges::view::chunk(256);
auto frontChunkFirst2 = readerChunks.front();

SECTION( "Checking size" ) {
    REQUIRE( readView2.size() == readView.size() );
}

}

That works ,

But if I change

static constexpr size_t MAX_FILE_SIZE = 10000; to 1000000

I am getting a segmentation fault.
And stack is like :

1   ____C_A_T_C_H____T_E_S_T____64  main.cpp    64  0x4095b1  
2   Catch::FreeFunctionTestCase::invoke catch.hpp   6294    0x42d7ed  
3   Catch::TestCase::invoke catch.hpp   7215    0x40412d  
4   Catch::RunContext::invokeActiveTestCase catch.hpp   5891    0x40e16e  
5   Catch::RunContext::runCurrentTest   catch.hpp   5862    0x40dab6  
6   Catch::RunContext::runTest  catch.hpp   5687    0x40e7e5  
7   Catch::runTests catch.hpp   6030    0x401e44  
8   Catch::Session::run catch.hpp   6138    0x42204b  
9   Catch::Session::run catch.hpp   6117    0x421f6e  
10  main    catch.hpp   10024   0x40907c    
@nabijaczleweli
Copy link
Contributor

You've under-/overflown the stack, increase the stack size in your linker arguments.

@kerdemdemir
Copy link
Author

But I have a question than; why I am not having this expection while I don't use "catch".

@nabijaczleweli
Copy link
Contributor

Because it stack-allocates some stuff as well?

@kerdemdemir
Copy link
Author

I set my max stack size like LIB += -Wl,--stack,4194304 but no matter what I do I am still getting the exception. This is most probably me who is not making the correct configuration. But I want to tell you anyways. I am on windows-mingw and configuring mingw with qmake.

@philsquared
Copy link
Collaborator

I didn't see this the first time around but I'm pretty sure this is just a case of "the straw that broke the camel's back".
I'm going to close it but if you're still watching, @kerdemdemir. and still think there is an issue please reopen and let us know your thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants