bigg
bigg copied to clipboard
Cubes example crashes (SIGSEGV) with no errors if executed from other directories
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:
-
mkdir build && cd build
-
cmake .. -DBIGG_EXAMPLES=ON
-
make
-
examples/cubes/cubes
<-- Crashes with SIGSEGV, no error messages -
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.