ReactNative calling QNetworkAccessManager on JNI method



  • I am development a ReactNative application that consumes a Qt C++ library.

    In one of my methods I make request to a Service and the application crashes. Follow the code:

    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    
    QEventLoop eventLoop;
    QNetworkRequest request;
    request.setUrl(QUrl("http://www.google.com"));
    
    connect(manager, SIGNAL(finished(QNetworkReply*)),
                    &eventLoop, SLOT(quit()));
    
    QNetworkReply *l_reply = manager->get(request); // App crashs in here
    eventLoop.exec();
    
    ...
    

    Stack Trace:

    09-15 07:33:31.331 10373 10617 F libc    : Fatal signal 11 (SIGSEGV), code 1, fault addr 0x0 in tid 10617 (AsyncTask #8)
    09-15 07:33:31.527 10620 10620 W crash_dump32: type=1400 audit(0.0:4139): avc: denied { search } for uid=10265 name="FastSeller" dev="sdcardfs" ino=32838 scontext=u:r:crash_dump:s0:c512,c768 tcontext=u:object_r:sdcardfs:s0 tclass=dir permissive=0
    09-15 07:33:31.554 10620 10620 I crash_dump32: obtaining output fd from tombstoned
    09-15 07:33:31.557  2343  2343 I /system/bin/tombstoned: received crash request for pid 10373
    09-15 07:33:31.559 10620 10620 I crash_dump32: performing dump of process 10373 (target tid = 10617)
    09-15 07:33:31.559 10620 10620 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    09-15 07:33:31.560 10620 10620 F DEBUG   : Build fingerprint: 'motorola/albus/albus:8.0.0/OPSS27.76-12-25-3/4:user/release-keys'
    09-15 07:33:31.560 10620 10620 F DEBUG   : Revision: 'p400'
    09-15 07:33:31.560 10620 10620 F DEBUG   : ABI: 'arm'
    09-15 07:33:31.560 10620 10620 F DEBUG   : pid: 10373, tid: 10617, name: AsyncTask #8  >>> br.com.polibras.polistore <<<
    09-15 07:33:31.560 10620 10620 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
    09-15 07:33:31.560 10620 10620 F DEBUG   : Cause: null pointer dereference
    09-15 07:33:31.560 10620 10620 F DEBUG   :     r0 00000000  r1 85ec9ffc  r2 00010006  r3 913d7fec
    09-15 07:33:31.560 10620 10620 F DEBUG   :     r4 aced71c8  r5 85ec9ffc  r6 90394953  r7 85eca084
    09-15 07:33:31.560 10620 10620 F DEBUG   :     r8 aced71c8  r9 90394976  sl 85eca0d8  fp aced71c8
    09-15 07:33:31.560 10620 10620 F DEBUG   :     ip 903a3fd4  sp 85ec9fc0  lr 911d5525  pc 911d5528  cpsr 40000030
    09-15 07:33:31.563 10620 10620 F DEBUG   : 
    09-15 07:33:31.563 10620 10620 F DEBUG   : backtrace:
    09-15 07:33:31.563 10620 10620 F DEBUG   :     #00 pc 00144528  /data/app/br.com.polibras.polistore-PUJTRJuAA5lrr3rW_PYpxg==/lib/arm/libQt5Core.so (_ZN22QJNIEnvironmentPrivateC1Ev+27)
    09-15 07:33:31.563 10620 10620 F DEBUG   :     #01 pc 00147a2b  /data/app/br.com.polibras.polistore-PUJTRJuAA5lrr3rW_PYpxg==/lib/arm/libQt5Core.so (_ZN17QJNIObjectPrivate23callStaticObjectMethodVEPKcS1_S1_St9__va_list+38)
    09-15 07:33:31.563 10620 10620 F DEBUG   :     #02 pc 00147b3f  /data/app/br.com.polibras.polistore-PUJTRJuAA5lrr3rW_PYpxg==/lib/arm/libQt5Core.so (_ZN17QJNIObjectPrivate22callStaticObjectMethodEPKcS1_S1_z+26)
    09-15 07:33:31.563 10620 10620 F DEBUG   :     #03 pc 00082fd3  /data/app/br.com.polibras.polistore-PUJTRJuAA5lrr3rW_PYpxg==/lib/arm/libQt5Network.so
    09-15 07:33:33.119   639  1020 I SFPerfTracer:      triggers: (rate: 0:0) (1880125 sw vsyncs) (0 skipped) (5096:3720646 vsyncs) (5098:5668645)
    

    Any suggestions?


  • Moderators

    Hi @Joselito

    Based on the snippet you don't create the QNetworkAccessManager at all, could it be as simple as creating the QNetworkAccessManager to solve the issue? Otherwise it looks fine so we would need a better stack trace to see where it crashes and why.



  • Hi,
    As @AndyS says, initialize QNetworkAccessManager then it will work perfectly. i wonder it would crash on connect rather than next line. If you have already initialized and it crashing then please share full code snippet.



  • Hi @AndyS

    I initialized QNetworkAccessManager in my code. Sorry about that. Snippet updated.

    Hi @TobbY,

    The crash happens inside the method "get".


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.