04-05-2012 06:52 AM
Dear all,
I have a mysterious problem that I don't quite know how to diagnose.
I am using sqlite (the almagamation file i.e. all of sqlite3 in one single file) with my app written in NDK 2.0.
I use it to dynamically create a database named "data/dan.db". When I am using the debug token for the debug-build, everything works. However, when I use the bar files produced from Export Release, the app simply crashes at launch. In fact, the problem seems to be the sqlite3_open() command. If I comment that out, the app loads. As soon as I put it back in, the app crashes.
I don't know why my app works fine with the build for the debug token but not as a release build.
Any help will be greatly appreciated.
Solved! Go to Solution.
04-09-2012 02:39 PM
Have you tried to catch error returned by sqlite3_open()?
04-09-2012 02:56 PM
I tried. But it crashes before the return code could be displayed.
I ended up packaging the binary from Device-Debug and it is running fine. I think there must be some compile flags that somehow cause the Release Build to crash. Maybe a compiler bug? I haven't quite figured out how to make the Release Build to use the exact same compilation flags in Momentics. Anyone has any idea?
04-09-2012 03:02 PM
Oh.. Once I've had the same problem but my app was not starting at all. I managed to 'fix' this by turning off 'Position Independent Executable flag' in compiler and linker.
You can compare all flags you use for Debug and Release build by going to Project's properties->C/C++ Build->Settings adn looking at QCC Compiler/Assembler/Linker when choosing different Build Types in Configuration field above all this stuff.
04-09-2012 03:13 PM
Thanks a million! It wasn't the Position Independent Execution flag that was causing the problem. It was the optimization level that caused the crash. The Debug Build has Optimization set to none. Setting the Release to none works! But setting it to O2 or O1 make it crash. It seems like something in sqlite3 doesn't like to be optimized.
04-17-2012 10:03 AM
If you want to find out exactly where your code is failing you can use pragma's to turn optimization off for specific functions. Or break your code out into different files and turn off optimizations for specific files. You can use divide-and-conquer to quickly isolate the section of code that is failing (if your crash is easily reproducible) .
#pragma GCC optimize("O0")
// Code you don't want optimized
#pragma GCC optimze("O2")
The likely culprit is most likely aliasing.
04-26-2012 09:42 PM
07-04-2012 03:36 AM - edited 07-04-2012 03:41 AM
Likewise, setting -O0 also solved the same issue for me. -O1 and -O2 in both crash.
07-05-2012 10:08 PM
I'm having a similar issue, release build crashes on startup.
However it only happens for some users after they download it from App World. I can't reproduce it by running the release build from the ndk.
I assume Blackberry tested the app before aproving it, so it seems a bit strange that this is happening.
I'll try to remove the optimization flags to see if that helps.
07-05-2012 11:13 PM
Some more details:
I don't use sqlite, the app is opengl es 2.0 based.
Also the user said that the playbook crashed after the first run after downloading from app world. Then only the application crashed.