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
Developer
canurabus
Posts: 23
Registered: ‎05-29-2012
My Device: PlayBook
Accepted Solution

Desperate for help with simple program crashing using Qt and stdlibc++

I have a really trivial example that I've been unable to get running no matter what I try. I'm using ndk2.0.1. The setup to recreate the problem is simple; the project needs to link to qt(4.8.2) and to stdlibc++ (not libcpp, libstdc++).

 

(main.cpp)

 

#include <iostream>
#include <sstream>
int main(int argc, char *argv[])
{
    std::cout << "This doesn't work\n";
    return 0;
}

 

That's it. You can use whatever toolchain you want (ntoxg++ or qcc), it doesn't seem to matter. If you use the qcc tool chain, you have to explicitly include the libstdc++ paths and link to it, since it uses libcpp by default. Build the project: it should compile fine. The bar-descriptor I used is here (http://pastie.org/4018541).

 

Create the bar file and deploy it. Once I start the program at this point, it'll show me the splashscreen for a few seconds and quit (crash) ... You'll notice:

* no log output (we expect something from the cout call)

* a nice core file waiting from the crash

 

Running the core file through ntox-gdb gives you:

#0  0xb8b5e329 in __gnu_cxx::__exchange_and_add (__mem=0x0, __val=-1)
    at atomicity.cc:36
36	atomicity.cc: No such file or directory.
	in atomicity.cc

(gdb) backtrace

#0  0xb8b5e329 in __gnu_cxx::__exchange_and_add (__mem=0x0, __val=-1)
    at atomicity.cc:36

#1  0xb8b03471 in __exchange_and_add_dispatch (__val=<optimized out>, 
    __mem=<optimized out>)
    at /home/builder/hudson/650-gcc-4.4/svn/linux-x86-o-ntox86/i486-pc-nto-qnx6.5.0/pic/libstdc++-v3/include/ext/atomicity.h:79

#2  _M_remove_reference (this=<optimized out>)
    at /home/builder/hudson/650-gcc-4.4/svn/linux-x86-o-ntox86/i486-pc-nto-qnx6.5.0/pic/libstdc++-v3/include/bits/locale_classes.h:505

#3  std::locale::~locale (this=0xb837d5fc, __in_chrg=<optimized out>)
    at ../../../../../libstdc++-v3/src/locale.cc:89

#4  0xb8b0faa9 in ~basic_streambuf (this=<optimized out>, 
    __in_chrg=<optimized out>)
    at /home/builder/hudson/650-gcc-4.4/svn/linux-x86-o-ntox86/i486-pc-nto-qnx6.5.0/pic/libstdc++-v3/include/streambuf:193

#5  std::basic_filebuf<char, std::char_traits<char> >::~basic_filebuf (
    this=0xb837d5e0, __in_chrg=<optimized out>)
    at /home/builder/hudson/650-gcc-4.4/svn/linux-x86-o-ntox86/i486-pc-nto-qnx6.5.0/pic/libstdc++-v3/include/fstream:215

#6  0xb0bbd205 in __cxa_finalize ()
   from /home/preet/bbndk-2.0.1/target/qnx6/x86/lib/libc.so.3

#7  0xb832de67 in _btext ()
   from /home/preet/bbndk-2.0.1/target/qnx6/x86/lib/libcpp.so.4

#8  0xb836a265 in _fini ()
   from /home/preet/bbndk-2.0.1/target/qnx6/x86/lib/libcpp.so.4

#9  0xb0bd46d3 in ?? ()
   from /home/preet/bbndk-2.0.1/target/qnx6/x86/lib/libc.so.3

#10 0xb0bd5d38 in ?? ()
   from /home/preet/bbndk-2.0.1/target/qnx6/x86/lib/libc.so.3

#11 0xb0bbd052 in _cleanup ()
   from /home/preet/bbndk-2.0.1/target/qnx6/x86/lib/libc.so.3

#12 0xb0bbd337 in exit ()
   from /home/preet/bbndk-2.0.1/target/qnx6/x86/lib/libc.so.3

#13 0x080487b0 in _start ()

I have no idea what to do with this stack trace and I haven't been able to debug the problem further.

 

This issue is especially messed up because I didn't even add any Qt code to the application yet; just linked to the libs. Not linking to the Qt libs will make this bit of code run fine. Linking to the Qt code with libcpp instead of libstdc++ will also make the code run as expected.

 

This problem's been driving me insane for the last coueple of days and I'd really really appreciate any help or advice. 

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer

Re: Desperate for help with simple program crashing using Qt and stdlibc++

How are you compiling?   qcc or QCC?  What options?

http://www.qnx.com/developers/docs/6.3.2/neutrino/utilities/q/qcc.html

 

I'm wondering if there is a version conflict, where you are linking against one version but have a different version installed on the device.  You may have more luck using QtCreator for PlayBook:

https://github.com/blackberry/Qt/downloads

 

Stuart

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer

Re: Desperate for help with simple program crashing using Qt and stdlibc++

Can you provide your makefile?

 

For Qt apps you should be using qmake and then make - are you using qcc/QCC directly?

 

Stuart

Please use plain text.
Developer
canurabus
Posts: 23
Registered: ‎05-29-2012
My Device: PlayBook

Re: Desperate for help with simple program crashing using Qt and stdlibc++

Thanks for the replies.

 

> How are you compiling?

I tried qmake intially (which calls qcc) and then tried gcc/g++ manually as well. Both give the same results. See the makefile for the options used for qcc (autogenerated with Qt): 

 

Just to be complete, here are all the files:

source file: http://pastie.org/4025238

pro file: http://pastie.org/4025259

bar file: http://pastie.org/4025254

auto-generated makefile: http://pastie.org/4029179

log and core dump (from device): http://pastie.org/4025285

 

> I'm wondering if there is a version conflict

not too sure what you mean here

 

Someone else on the #BlackBerryDev channel noted coming across a similar issue. 

Please use plain text.
BlackBerry Development Advisor (Retired)
smacmartin
Posts: 499
Registered: ‎05-07-2012
My Device: developer

Re: Desperate for help with simple program crashing using Qt and stdlibc++

Have you straightened out your build?

You had a related question in http://supportforums.blackberry.com/t5/Native-Development/Confusion-regarding-the-two-c-libs-include...

 

Did the subsequent threads on the native forum discussing setting up the environment for Qt answer your questions, or is this a separate issue?

 

Stuart

Please use plain text.
Developer
canurabus
Posts: 23
Registered: ‎05-29-2012
My Device: PlayBook

Re: Desperate for help with simple program crashing using Qt and stdlibc++

The KDAB guys have told me its a bug and that they're looking into it.

Please use plain text.
Regular Contributor
robinhuang
Posts: 52
Registered: ‎02-08-2013
My Device: Z10

Re: Desperate for help with simple program crashing using Qt and stdlibc++

Is it fixed. I found the Cascasde application still crash if using stdlibc++. I have to use libcpp. Please confirm.

Please use plain text.