Question

I've been struggling to fix some final bugs in our game. The game uses Android port of Irrlicht and Bullet physics.

The same code was tried on OS X and Windows without any problem. However, when we ported the code to Android NDK and now get random crashes. Most of the crashes are in libc.so which is probably kinda nullpointerexception. We do not use scenenode->remove() in our code, instead smgr->addToDeletionQueue.

The crash is so random that it occurs in the following statements.

  1. libc.so
  2. smgr->drawall()
  3. stepsimulation in bullet.

The error occurs 90% of the time when we unload a level and load next level or reload a level. We first doubted on compiler and used stlport. Should boost library help?

I am sure, the information I've provided is very little to guess the problem. But since the same game code worked fine on other platforms, I just wanted to clear my doubts on compiler related differences.

A simple malloc and then delete in android ndk crashes at delete. So I wanted to have a better understanding if what we are struggling to fix is a stupid problem related to compilers.

Was it helpful?

Solution

After fiddling with this problem for a couple of weeks, I finally found the source of the problem.

I initiallized a char array like this

char data = new char[10];

and then considered filling the last char as usual with '\0'

data[10] = '\0';

which throw a nullpointer exception.

I was able to pin point this problem when I run the same code in Windows. Even on windows the problem didn't show-up when running with debugger attached. however, when I run the app by opening the exe directly it crashed. So I had to use the program "Application Verifier" to pin point the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top