In Android getting crash when calling sendFINDRequest

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
himanshu.mistri
Posts: 18
Joined: Tue, 2018-06-05, 10:21

In Android getting crash when calling sendFINDRequest

#1 Post by himanshu.mistri » Thu, 2020-07-23, 17:33

Hi OFFIS,

I am using dcmtk on android, So far C-ECHO, C-STORE works fine with the use of the DcmSCU from the Lib version 3.6.5.
Since i have included all module of dcmtk, This class will be also part going to be part of my single so file. https://github.com/DCMTK/dcmtk/blob/DCM ... src/scu.cc

I am using the C-FIND request like below:-

Code: Select all

class DcmClient : public DcmSCU
{

public:
    DcmClient()  {

    }

    ~DcmClient() {

    }
};
Then below is how i configure Client:-

Code: Select all

 DcmClient mDcmScu;
    OFLog::configure(OFLogger::DEBUG_LOG_LEVEL);
    mDcmScu.setAETitle(thorAeTitle);
    mDcmScu.setPeerHostName(pacsIpAddress);
    mDcmScu.setPeerPort(pacsHostPort);
    mDcmScu.setPeerAETitle(pacsAeTitle);
    mDcmScu.setDIMSEBlockingMode(DIMSE_NONBLOCKING);
    mDcmScu.setDIMSETimeout(60);
    mDcmScu.setMaxReceivePDULength(ASC_DEFAULTMAXPDU);

    mDcmScu.setVerbosePCMode(OFTrue);

    OFList<OFString> ts;
    ts.emplace_back(UID_LittleEndianExplicitTransferSyntax);
    ts.emplace_back(UID_BigEndianExplicitTransferSyntax);
    ts.emplace_back(UID_LittleEndianImplicitTransferSyntax);
 
    mDcmScu.addPresentationContext(UID_FINDModalityWorklistInformationModel, ts);
   mDcmScu.initNetwork();
   mDcmScu.negotiateAssociation();
   T_ASC_PresentationContextID presID = mDcmScu.findPresentationContextID(UID_FINDModalityWorklistInformationModel, "");
     OFList<QRResponse*> *findResponses;
     findResponses=new OFList<QRResponse*>();
   //Below is the line where my android app crash with native dump which is hard to find the root cause.
   cond = mDcmScu.sendFINDRequest(presID, &req, findResponses);

Crash strace from android: Since sendFINDRequest is part of libdcmtk.so , I am not getting any logs from scu class.

Code: Select all

    --------- beginning of crash
2020-07-18 21:35:00.277 4142-4218/com.xxx.yyyy A/libc: Fatal signal 5 (SIGTRAP), code 1 in tid 4218 (DefaultDispatch), pid 4142 (xxx.yyyy)
2020-07-18 21:35:00.326 789-789/? E/HWComposer: getLayerReleaseFence: Invalid display
2020-07-18 21:35:00.326 789-789/? E/HWComposer: getLayerReleaseFence: Invalid display
2020-07-18 21:35:00.365 4276-4276/? I/crash_dump64: obtaining output fd from tombstoned, type: kDebuggerdTombstone
2020-07-18 21:35:00.365 1291-1291/? I//system/bin/tombstoned: received crash request for pid 4142
2020-07-18 21:35:00.366 4276-4276/? I/crash_dump64: performing dump of process 4142 (target tid = 4218)
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG: Build fingerprint: 'Android/msm8998/msm8998:8.1.0/1.0.42/42:user/test-keys'
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG: Revision: '0'
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG: ABI: 'arm64'
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG: pid: 4142, tid: 4218, name: DefaultDispatch  >>> com.xxx.yyyy <<<
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG: signal 5 (SIGTRAP), code 1 (TRAP_BRKPT), fault addr 0x781805f064
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG:     x0   0000000000000020  x1   373bed87a9cac858  x2   0000000000000004  x3   0000000000000008
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG:     x4   0000000000000000  x5   000000781afff588  x6   000000781afff588  x7   000000781afff588
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG:     x8   0000000000000042  x9   373bed87a9cac858  x10  373bed87a9cac858  x11  373bed87a9cac858
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG:     x12  373bed87a9cac858  x13  0000000000000000  x14  373bed87a9cac858  x15  373bed87a9cac858
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG:     x16  000000781afff588  x17  00000078c93fee6c  x18  373bed87a9cac858  x19  000000781eb27800
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG:     x20  000000784706fea0  x21  000000781eb27800  x22  000000781affd99c  x23  000000782ecf8ae9
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG:     x24  000000000000000c  x25  000000781afff588  x26  000000781eb278a0  x27  0000000000000003
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG:     x28  0000000000000004  x29  000000781affc720  x30  000000781805f064
2020-07-18 21:35:00.368 4276-4276/? A/DEBUG:     sp   000000781affc6f0  pc   000000781805f064  pstate 0000000060000000
2020-07-18 21:35:00.370 4276-4276/? A/DEBUG: backtrace:
I am facing one interesting here.

If i use this cpp class into my own code in android then build above code , In this case it works fine. https://github.com/DCMTK/dcmtk/blob/DCM ... src/scu.cc

Any clue why i have to add again scu.cc in my own so file, Because its' already presented into the libdcmtk.so. Also if i am using scu.cc class as it is will that cause any license issue?

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1280
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: In Android getting crash when calling sendFINDRequest

#2 Post by Marco Eichelberg » Wed, 2020-07-29, 07:27

I am not an Android developer; I hope my comments apply for development on Android:
  • It should be possible to compile a debug build of a shared object and get a stack trace indicating where (in the source code) the crash happens. Without that, this will be a guessing exercise.
  • When you have the same class twice in your code, once in the main app and once in a shared object, that can lead to obscure problems related to memory management of global objects (e.g. static variables). I do not understand why linking scu.cc into your app makes the crash disappear, but I could imagine that with this "solution" you create another problem that will cause crashes at a later time in the code.
  • The signal that causes the crash here is SIGTRAP. As far as I know, system functions never raise SIGTRAP. This is normally used by a debugger to stop code at a breakpoint. You may either be using code that is instrumented to run in the debugger (but running it without the debugger), or SIGTRAP might be an indication of a heap memory corruption.

J. Riesmeier
DCMTK Developer
Posts: 2284
Joined: Tue, 2011-05-03, 14:38
Location: Oldenburg, Germany
Contact:

Re: In Android getting crash when calling sendFINDRequest

#3 Post by J. Riesmeier » Wed, 2020-07-29, 09:55

Also if i am using scu.cc class as it is will that cause any license issue?
The public DCMTK (including scu.cc) is made available under a BSD license (see COPYRIGHT file for details). So, as long as you comply with the listed terms and conditions there is no issue.

himanshu.mistri
Posts: 18
Joined: Tue, 2018-06-05, 10:21

Re: In Android getting crash when calling sendFINDRequest

#4 Post by himanshu.mistri » Tue, 2020-08-11, 18:03

Thank you all for the response.

After rebuilding the libdcmtk.so again on the linux machine. This time for the build type I have selected RelWithDebInfo on the CMake.
Now I am not getting the crash on android.

Marco Eichelberg
OFFIS DICOM Team
OFFIS DICOM Team
Posts: 1280
Joined: Tue, 2004-11-02, 17:22
Location: Oldenburg, Germany
Contact:

Re: In Android getting crash when calling sendFINDRequest

#5 Post by Marco Eichelberg » Thu, 2020-08-27, 12:01

That sounds like heap memory corruption. Unfortunately, such errors are hard to debug. Check if memory debuggers such as valgrind, dmalloc or the various -fsanitize options in gcc or clang can be used on your platform.

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest