Segmentation Fault at the creation of a DicomImage

All other questions regarding DCMTK

Moderator: Moderator Team

Post Reply
Message
Author
malf
Posts: 10
Joined: Fri, 2011-09-02, 14:29
Location: BRAZIL

Segmentation Fault at the creation of a DicomImage

#1 Post by malf »

Hi guys!

I've noted that sometimes when I load a dicom file my program gets a segmentation fault at the creation of a DicomImage.
Debugging the stack it's always at the constructor of a OFString.
The stack at this point looks like:


OFString::OFString() + 0x30 bytes C++ [SEGMENTATION FAULT]
DiDocument::convertPixelData() + 0x5f3 bytes C++
DiDocument::DiDocument() + 0xc7 bytes C++
DicomImage::DicomImage() + 0x78 bytes C++


I am creating a DicomImage like this:

Code: Select all

new DicomImage(&dicomfile, xfer, CIF_AcrNemaCompatibility); 
I've noted that most of the files that I gets this problem have a multilevel data. Do you have an idea what's wrong?

Thanks!!

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

#2 Post by J. Riesmeier »

Did you already check whether the memory is exhausted?

malf
Posts: 10
Joined: Fri, 2011-09-02, 14:29
Location: BRAZIL

#3 Post by malf »

Hum, I don't think that the problem is the memory. I used the original binary "dcmj2pnm.exe" to convert this dicom file to a image and worked well. Besides that the file that I am using is quite small, like 300KB.

It's probably some programming error of mine.

I am trying to use this dataset: http://barre.nom.fr/medical/samples/

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

#4 Post by J. Riesmeier »

What about more details on your program, e.g. which version of the DCMTK are you using. Is USE_NULL_SAFE_OFSTRING defined when compiling your program? And so on ...

malf
Posts: 10
Joined: Fri, 2011-09-02, 14:29
Location: BRAZIL

#5 Post by malf »

Right! Some useful information:

1) My DcmFileFormat is created like this:

Code: Select all

dicomfile->loadFile(filepath, EXS_Unknown, EGL_withoutGL, DCM_MaxReadLength, ERM_autoDetect);
2) Dcmtk version 3.6.0 compiled as VC9 MD lib
3) Compiler VC9
4) USE_NULL_SAFE_OFSTRING is defined!
Last edited by malf on Fri, 2011-10-21, 13:43, edited 1 time in total.

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

#6 Post by J. Riesmeier »

Regarding 4) see the following commit as well as the documentation in "macros.txt".

malf
Posts: 10
Joined: Fri, 2011-09-02, 14:29
Location: BRAZIL

#7 Post by malf »

Ok. I've check my generation of the OFString and the MACRO USE_NULL_SAFE_OFSTRING was there. So, I am using this! Other idea?

malf
Posts: 10
Joined: Fri, 2011-09-02, 14:29
Location: BRAZIL

#8 Post by malf »

This other file "CR-MONO1-10-chest" the segmentation fault happened with the stack like this:


msvcr90d.dll!memmove(unsigned char * dst=0x03528a00, unsigned char * src=0x0000000f, unsigned long count=1) Line 348 Asm
OFString::assign() + 0x5a bytes C++
OFString::OFString() + 0x23 bytes C++
InternalLoggingEvent::InternalLoggingEvent() + 0x4a bytes C++
LoggerImpl::forcedLog() + 0x70 bytes C++
DiImage::DiImage() + 0x1220 bytes C++
DiMonoImage::DiMonoImage() + 0x3c bytes C++


Always in the OFString class.

malf
Posts: 10
Joined: Fri, 2011-09-02, 14:29
Location: BRAZIL

#9 Post by malf »

Some file examples for the first stack seg. fault:

-MR-MONO2-12-shoulder (SINGLE FRAME)
DICOM
JPEG (57)
MR
MONOCHROME2
1024x1024
[12, 16 | 11], PR=0
Philips Med. Syst.
Gyroscan NT (RTNC1)


-US-RGB-8-epicard (SINGLE FRAME)
DICOM
Explicit Big
US
RGB (byplane)
640x480
[8, 8 | 7], PR=0
G.E. Med. Syst.
Logic 700 (R6.1)


-CT-MONO2-16-chest (SINGLE FRAME)
DICOM
JPEG (70)
CT
MONOCHROME2
512x400
[16, 16 | 15], PR=1
G.E. Med. Syst.
HiSpeed (Series 2.00)


-XA-MONO2-8-12x-catheter (MULTIPLE FRAMES)
DICOM
JPEG (70)
XA
MONOCHROME2
12x512x512
[8, 8 | 7]
Acme Products


-US-PAL-8-10x-echo (MULTIPLE FRAMES)
DICOM
RLE lossless
US
PALETTE COLOR
10x630x400
[8, 8 | 7]
Acme Products
Last edited by malf on Fri, 2011-10-21, 14:17, edited 1 time in total.

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

#10 Post by J. Riesmeier »

If your program crashes but the original "dcmj2pnm" works, then the problem is apparently with your program (which I do not know). What about using a debugger to find the reason for the crash?

malf
Posts: 10
Joined: Fri, 2011-09-02, 14:29
Location: BRAZIL

#11 Post by malf »

I can't right now because I am using DCMTK as an external lib (VC9 MD). My creation of the DcmFileFormat and DicomImage are OK ?

Post Reply

Who is online

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