Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Trusted Contributor
sucroid
Posts: 195
Registered: ‎03-12-2012
My Device: PlayBook
My Carrier: None
Accepted Solution

App crashes only when in release build

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.

Sucroid.com
Sweet Apps for the Fans
Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: App crashes only when in release build

Have you tried to catch error returned by sqlite3_open()?

Please use plain text.
Trusted Contributor
sucroid
Posts: 195
Registered: ‎03-12-2012
My Device: PlayBook
My Carrier: None

Re: App crashes only when in release build

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?

Sucroid.com
Sweet Apps for the Fans
Please use plain text.
Developer
BGmot
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: App crashes only when in release build

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.

Please use plain text.
Trusted Contributor
sucroid
Posts: 195
Registered: ‎03-12-2012
My Device: PlayBook
My Carrier: None

Re: App crashes only when in release build

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.

Sucroid.com
Sweet Apps for the Fans
Please use plain text.
New Developer
npross
Posts: 29
Registered: ‎02-26-2012
My Device: Playbook, Bold 9900
My Carrier: Telus

Re: App crashes only when in release build

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.
Please use plain text.
Regular Visitor
Kydo
Posts: 1
Registered: ‎03-25-2012
My Device: PlayBook
My Carrier: Fido

Re: App crashes only when in release build

Setting the Optimization to none worked for me too! Thanks!
Please use plain text.
Developer
sketch34
Posts: 54
Registered: ‎05-23-2012
My Device: Developer
My Carrier: Developer

Re: App crashes only when in release build

[ Edited ]

Likewise, setting -O0 also solved the same issue for me. -O1 and -O2 in both crash.

----
I know exactly where the problem *might* be.
Please use plain text.
Contributor
asymmetryg
Posts: 12
Registered: ‎03-25-2012
My Device: none
My Carrier: none

Re: App crashes only when in release build

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.

Please use plain text.
Contributor
asymmetryg
Posts: 12
Registered: ‎03-25-2012
My Device: none
My Carrier: none

Re: App crashes only when in release build

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.

Please use plain text.