Segfault between DCMTK and pytorch lite

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
zaviercheng
Posts: 3
Joined: Wed, 2023-07-12, 14:27

Segfault between DCMTK and pytorch lite

#1 Post by zaviercheng »

I'm working on a android app with both DCMTK and pytorch lite SDK.
I encounter the segmentation fault when loading my pytorch model.
Here is the logcat messages. Please help! Thank you.

Fatal signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 0x7fda774ea8 in tid 12971 (myapp), pid 12971 (myapp)
pid-13279 A Cmdline: com.my.myapp
pid-13279 A pid: 12971, tid: 12971, name: myapp >>> com.my.myapp <<<
pid-13279 A #01 pc 00000000000eab24 /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libc++_shared.so (BuildId: a777ae836b797ddfce8ce3564b3b5d6565a0ab08)
pid-13279 A #02 pc 00000000000ea818 /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libc++_shared.so (BuildId: a777ae836b797ddfce8ce3564b3b5d6565a0ab08)
pid-13279 A #03 pc 00000000000e6e30 /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libc++_shared.so (BuildId: a777ae836b797ddfce8ce3564b3b5d6565a0ab08)
pid-13279 A #04 pc 00000000000e6c60 /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libc++_shared.so (__gxx_personality_v0+128) (BuildId: a777ae836b797ddfce8ce3564b3b5d6565a0ab08)
pid-13279 A #05 pc 00000000000d03cc /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libofstd.so (_Unwind_RaiseException+180) (BuildId: 04729f14bc03ace5b427038b9aeed716c1aabd6b)
pid-13279 A #06 pc 00000000000b7c44 /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libofstd.so (__cxa_throw+112) (BuildId: 04729f14bc03ace5b427038b9aeed716c1aabd6b)
pid-13279 A #07 pc 00000000000c274c /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libc++_shared.so (BuildId: a777ae836b797ddfce8ce3564b3b5d6565a0ab08)
pid-13279 A #08 pc 0000000000098704 /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libc++_shared.so (std::__ndk1::locale::use_facet(std::__ndk1::locale::id&) const+180) (BuildId: a777ae836b797ddfce8ce3564b3b5d6565a0ab08)
pid-13279 A #09 pc 000000000048b278 /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.leltek.leltekultrasound-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libpytorch_jni_lite.so (BuildId: c4c23dc7eb04cacc035cb308a69aacf71e383ab5)
pid-13279 A #10 pc 0000000001993604 /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.leltek.leltekultrasound-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libpytorch_jni_lite.so (BuildId: c4c23dc7eb04cacc035cb308a69aacf71e383ab5)
pid-13279 A #11 pc 0000000001992454 /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libpytorch_jni_lite.so (torch::Library::_impl(char const*, torch::CppFunction&&) &+792) (BuildId: c4c23dc7eb04cacc035cb308a69aacf71e383ab5)
pid-13279 A #12 pc 0000000000a52308 /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libpytorch_jni_lite.so (BuildId: c4c23dc7eb04cacc035cb308a69aacf71e383ab5)
pid-13279 A #13 pc 0000000000a52184 /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libpytorch_jni_lite.so (BuildId: c4c23dc7eb04cacc035cb308a69aacf71e383ab5)
pid-13279 A #14 pc 000000000045fe80 /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!libpytorch_jni_lite.so (BuildId: c4c23dc7eb04cacc035cb308a69aacf71e383ab5)
pid-13279 A #34 pc 00000000003bc65c [anon:dalvik-classes.dex extracted in memory from /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk] (com.facebook.soloader.nativeloader.SystemDelegate.loadLibrary+0)
pid-13279 A #36 pc 00000000003bc4c8 [anon:dalvik-classes.dex extracted in memory from /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk] (com.facebook.soloader.nativeloader.NativeLoader.loadLibrary+16)
pid-13279 A #38 pc 00000000003bc49e [anon:dalvik-classes.dex extracted in memory from /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk] (com.facebook.soloader.nativeloader.NativeLoader.loadLibrary+2)
pid-13279 A #40 pc 000000000022dc90 [anon:dalvik-classes12.dex extracted in memory from /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!classes12.dex] (org.pytorch.LiteNativePeer.<clinit>+32)
pid-13279 A #46 pc 000000000022dbb0 [anon:dalvik-classes12.dex extracted in memory from /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!classes12.dex] (org.pytorch.LiteModuleLoader.load+0)
pid-13279 A #51 pc 000000000005c894 [anon:dalvik-classes5.dex extracted in memory from /data/app/~~HOabB6UorhHwZYrTZqyNlA==/com.my.myapp-K5RfDRrHFRQyn-Oun8_-Aw==/base.apk!classes5.dex] (com.my.myapp.MainActivity2.onCreate+40)

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

Re: Segfault between DCMTK and pytorch lite

#2 Post by J. Riesmeier »

I cannot see any connection with the DCMTK. You should probably start the debugger to find the reason for this segmentation fault.

zaviercheng
Posts: 3
Joined: Wed, 2023-07-12, 14:27

Re: Segfault between DCMTK and pytorch lite

#3 Post by zaviercheng »

The libofstd.so is a basic operation library in DCMTK, and it conflicts with libpytorch_jni_lite.so then cause this segfault

zaviercheng
Posts: 3
Joined: Wed, 2023-07-12, 14:27

Re: Segfault between DCMTK and pytorch lite

#4 Post by zaviercheng »

J. Riesmeier wrote: Thu, 2023-07-13, 08:48 I cannot see any connection with the DCMTK. You should probably start the debugger to find the reason for this segmentation fault.
Appreciate the reply. Any suggestions to find what would be the reason the libofstd.so is conflict with libpytorch_jni_lite.so?

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

Re: Segfault between DCMTK and pytorch lite

#5 Post by Marco Eichelberg »

I don't think that it is possible to determine the reason for the segmentation fault from the stack trace alone. As Jörg Riesmeier wrote, you really need to get this running in a debugger to determine the precise function call that causes the segfault. Possible reasons could be either an identical symbol name that occurs in both libraries, causing the wrong function/method to be called, or perhaps both libraries are compiled against different versions of the standard libraries (libc, libstdc++ etc.), which might also explain the issue.

Michael Onken
DCMTK Developer
Posts: 2067
Joined: Fri, 2004-11-05, 13:47
Location: Oldenburg, Germany
Contact:

Re: Segfault between DCMTK and pytorch lite

#6 Post by Michael Onken »

Or it's a memory issue when handling over objects/memory areas from jni to ofstd and/or back.

Post Reply

Who is online

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