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

Cubes example crashes (SIGSEGV) with no errors if executed from other directories #30

Open
dejaime opened this issue Feb 18, 2021 · 0 comments

Comments

@dejaime
Copy link

dejaime commented Feb 18, 2021

In the ExampleCubes::initialize function the application builds a relative path to the files (v/f)s_cubes.bin. If your working directory is the same as the application, it works fine, but crashes if you try to execute from any other directory.

How to reproduce:

  1. mkdir build && cd build
  2. cmake .. -DBIGG_EXAMPLES=ON
  3. make
  4. examples/cubes/cubes <-- Crashes with SIGSEGV, no error messages
  5. cd examples/cubes && cubes <-- Works fine

Crash happens on cubes.cpp:78, mProgram = bigg::loadProgram( vsName, fsName );, actually inside of bigg::loadProgram.

Fixing the example so that the file loading works independently from the working directory would be nice.
But this still leaves an undesirable behavior for anyone using the bigg framework, as bigg::loadProgram simply crashes without any error output in case the parameters passed to it are invalid. As a user, I can either use exceptions or do something like this (resulting in unnecessary file open/close calls):

std::ifstream tesingVS( vsName, std::ios::binary | std::ios::ate );
std::ifstream tesingFS( fsName, std::ios::binary | std::ios::ate );

if (tesingFS.is_open() && testingVS.is_open()) {
    testingVS.close();
    testingFS.close();
    mProgram = bigg::loadProgram( vsName, fsName );
} else {
    //Return some error or crash out
    std::cerr<<"Failed opening file " << vsName << " or " << fsName << std::endl;
    exit(EXIT_CODE);
}
//Continue

Though I guess I'd be satisfied if the function outputted some "failed to open file" logs to cerr before crashing out.

@dejaime dejaime changed the title Cubes example crashes (SIGSEGV) if executed from other directories Cubes example crashes (SIGSEGV) with no errors if executed from other directories Feb 18, 2021
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

1 participant