im trying to find the cause of the following crash reported on android:
crash at (operator new(unsigned int)+22)
does it mean that memory was not allocated successfully ? and if so, adding std::nothrow and null check and exit the program is the right solution?
is there a way i can limit the program to not allocate in order to reproduce it ?
the code where it crash :
glCompileShader( VSID );
GLint vstat;
glGetShaderiv( VSID, GL_COMPILE_STATUS, &vstat );
if( vstat != GL_TRUE )
{
GLint infolen;
glGetShaderiv( VSID, GL_INFO_LOG_LENGTH, &infolen );
GLchar* infostring = new GLchar[infolen + 1];
glGetShaderInfoLog( VSID, infolen, nullptr, infostring );
infostring[infolen] = 0;
std::stringstream Error;
Error << "An Error occured while trying to compile"\
" Vertex Shader \"" << VertexShaderPath
<< "\":\n\n" << infostring;
}
A crash in operator new
or new[]
can be caused by:
infolen
is too large compared to the available memory. GLchar
, this is not very probable. You should add code to handle the exception, by enclosing new in a try
..catch
block (as demonstrated here) so to terminate graciously.
If you invoke new with nothrow
you should then check the returned pointer for being different than nullptr
in order to avoid nasty UB.