Re: [ITK-users] [ITK] ImageSeriesReader type pointer crashes in debug mode
Ritesh Mahajan <[email protected]> Tue, 25 Sep 2018 21:32:31 +0530 (IST)
| Newsgroups | gmane.comp.lib.itk.user |
|---|---|
| Message-ID | <[email protected]> |
--===============0897448687==
Content-Type: multipart/alternative;
boundary="----=_Part_86098_997975555.1537891351774"
------=_Part_86098_997975555.1537891351774
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Thanks for reply. I shared the same issue with forum as well under communit=
y category. Please find the below code. This is simple cpp file containing =
function to read dicom. In which the dicomReader pointer is made global. Th=
is code runs in release mode and crahes in debug mode. While debugging i fo=
und that i crashes in itkImageSource class under template< typename TOutput=
Image > ImageSource< TOutputImage >::ImageSource().=20
// itk headers=20
#include "itkGDCMImageIO.h"=20
#include "itkGDCMSeriesFileNames.h"=20
#include "itkImageSeriesReader.h"=20
#include "itkImageSeriesWriter.h"=20
#include "itksys/SystemTools.hxx"=20
#include "itkVersion.h"=20
#include "itkImage.h"=20
#include "gdcmUIDGenerator.h"=20
#include "itkFileOutputWindow.h"=20
#include "DicomReader.hpp"=20
using namespace std;=20
typedef signed short PixelType;=20
typedef itk::Image< PixelType, 3> ImageType;=20
typedef itk::ImageSeriesReader< ImageType > ReaderType;=20
typedef itk::GDCMImageIO ImageIOType;=20
typedef itk::GDCMSeriesFileNames NamesGeneratorType;=20
ReaderType::Pointer dicomReader=3D ReaderType::New();=20
void ParseDicom(const string &dicomDirectory)=20
{=20
NamesGeneratorType::Pointer apNamesGenerator =3D NamesGeneratorType::New();=
=20
ImageIOType::Pointer apGdcmIO =3D ImageIOType::New();=20
apNamesGenerator->SetInputDirectory(dicomDirectory);=20
const ReaderType::FileNamesContainer & filenames =3D=20
apNamesGenerator->GetInputFileNames();=20
dicomReader ->SetImageIO(apGdcmIO);=20
dicomReader ->SetFileNames(filenames);=20
try=20
{=20
dicomReader ->Update();=20
}=20
catch (itk::ExceptionObject &excp)=20
{=20
std::cerr << "exception in file reader " << std::endl;=20
throw (excp);=20
}=20
}=20
From: "D=C5=BEenan Zuki=C4=87" <[email protected]>=20
To: "ritesh mahajan" <[email protected]>=20
Cc: "insight-users" <[email protected]>=20
Sent: Tuesday, September 25, 2018 8:16:52 PM=20
Subject: Re: [ITK] [ITK-users] ImageSeriesReader type pointer crashes in de=
bug mode=20
Hi Ritesh,=20
When code crashes in Debug mode, but runs in Release or vice versa, it mean=
s it has a deficiency (bug) which manifests in one of those modes. As you d=
id not provide the code which uses the reader, I cannot offer any more spec=
ific advice. Providing a runnable example will make it easier for people to=
help you.=20
We have transitioned away from this list, to the forum . Please post your u=
pdated question there, as more people will see it.=20
Regards,=20
D=C5=BEenan=20
On Tue, Sep 25, 2018 at 1:45 AM ritesh.mahajan < [email protected]=
com > wrote:=20
Hello Team,=20
When i am creating a smart pointer globally and allocating the memory to it=
.=20
In debug mode "it crashes". While when the same code is run in release mode=
=20
it seems to work fine. Can some one help me out why is it so ?=20
Please find the below code:=20
typedef signed short PixelType;=20
typedef itk::Image< PixelType, 3>ImageType;=20
typedef itk::ImageSeriesReader< ImageType >ReaderType;=20
ReaderType:: Pointer reader=3D ReaderType::New();=20
void ImageRead()=20
{=20
// using pointer reader here.=20
// which is allocated memory at global level=20
}=20
The above code crashes in debug mode=20
--=20
Sent from: http://itk-users.7.n7.nabble.com/=20
The ITK community is transitioning from this mailing list to discourse.itk.=
org . Please join us there!=20
________________________________=20
Powered by www.kitware.com=20
Visit other Kitware open-source projects at=20
http://www.kitware.com/opensource/opensource.html=20
Kitware offers ITK Training Courses, for more information visit:=20
http://www.kitware.com/products/protraining.php=20
Please keep messages on-topic and check the ITK FAQ at:=20
http://www.itk.org/Wiki/ITK_FAQ=20
Follow this link to subscribe/unsubscribe:=20
https://itk.org/mailman/listinfo/insight-users=20
The ITK community is transitioning from this mailing list to discourse.itk.=
org . Please join us there!=20
________________________________________=20
Community mailing list=20
[email protected]=20
https://itk.org/mailman/listinfo/community=20
------=_Part_86098_997975555.1537891351774
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
<html><body><div style=3D"font-family: arial, helvetica, sans-serif; font-s=
ize: 12pt; color: #000000"><div>Thanks for reply. I shared the same issue w=
ith forum as well under community category. Please find the below code. Thi=
s is simple cpp file containing function to read dicom. In which the dicomR=
eader pointer is made global. This code runs in release mode and crahes in =
debug mode. While debugging i found that i crashes in itkImageSource class =
under template< typename TOutputImage > ImageSource< TOutputI=
mage >::ImageSource().<br><br></div><div>// itk headers<br>#include "itk=
GDCMImageIO.h"<br>#include "itkGDCMSeriesFileNames.h"<br>#include "itkImage=
SeriesReader.h"<br>#include "itkImageSeriesWriter.h"<br>#include "itksys/Sy=
stemTools.hxx"<br>#include "itkVersion.h"<br>#include "itkImage.h"<br>#incl=
ude "gdcmUIDGenerator.h"<br>#include "itkFileOutputWindow.h"<br>#include "D=
icomReader.hpp"</div><div><br data-mce-bogus=3D"1"></div><div>using namespa=
ce std;<br><br>typedef signed short PixelType;<br>typedef itk::Image< Pi=
xelType, 3> ImageType;<br>typedef itk::ImageSeriesReader< ImageType &=
gt; ReaderType;<br>typedef itk::GDCMImageIO ImageIOType;<br>typedef itk::GD=
CMSeriesFileNames NamesGeneratorType;</div><div><br>ReaderType::Pointer dic=
omReader=3D ReaderType::New();<br><br>void ParseDicom(const string &dic=
omDirectory)<br>{<br> NamesGeneratorType::Pointer apNamesGenerator =3D Name=
sGeneratorType::New();<br> ImageIOType::Pointer apGdcmIO =3D ImageIOType::N=
ew();<br><br> apNamesGenerator->SetInputDirectory(dicomDirectory);</div>=
<div><br> const ReaderType::FileNamesContainer & filenames =3D<br> apNa=
mesGenerator->GetInputFileNames();</div><div><br><span style=3D"color: #=
000000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-st=
yle: normal; font-variant-ligatures: normal; font-variant-caps: normal; fon=
t-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-=
indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spa=
cing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-=
decoration-style: initial; text-decoration-color: initial; display: inline =
!important; float: none;" data-mce-style=3D"color: #000000; font-family: ar=
ial, helvetica, sans-serif; font-size: 16px; font-style: normal; font-varia=
nt-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-s=
pacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-trans=
form: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text=
-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initi=
al; text-decoration-color: initial; display: inline !important; float: none=
;">dicomReader</span>->SetImageIO(apGdcmIO);<br><span style=3D"color: #0=
00000; font-family: arial, helvetica, sans-serif; font-size: 16px; font-sty=
le: normal; font-variant-ligatures: normal; font-variant-caps: normal; font=
-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-i=
ndent: 0px; text-transform: none; white-space: normal; widows: 2; word-spac=
ing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-d=
ecoration-style: initial; text-decoration-color: initial; display: inline !=
important; float: none;" data-mce-style=3D"color: #000000; font-family: ari=
al, helvetica, sans-serif; font-size: 16px; font-style: normal; font-varian=
t-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-sp=
acing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transf=
orm: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-=
stroke-width: 0px; background-color: #ffffff; text-decoration-style: initia=
l; text-decoration-color: initial; display: inline !important; float: none;=
">dicomReader</span>->SetFileNames(filenames);<br> try<br> {<br><span st=
yle=3D"color: #000000; font-family: arial, helvetica, sans-serif; font-size=
: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-ca=
ps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-alig=
n: start; text-indent: 0px; text-transform: none; white-space: normal; wido=
ws: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color:=
#ffffff; text-decoration-style: initial; text-decoration-color: initial; d=
isplay: inline !important; float: none;" data-mce-style=3D"color: #000000; =
font-family: arial, helvetica, sans-serif; font-size: 16px; font-style: nor=
mal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight=
: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: =
0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0p=
x; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decorati=
on-style: initial; text-decoration-color: initial; display: inline !importa=
nt; float: none;">dicomReader</span>->Update();<br> }<br> catch (itk::Ex=
ceptionObject &excp)<br> {<br> std::cerr << "exception in file re=
ader " << std::endl;<br> throw (excp);<br> }</div><div>}</div><hr id=
=3D"zwchr" data-marker=3D"__DIVIDER__"><div data-marker=3D"__HEADERS__"><b>=
From: </b>"D=C5=BEenan Zuki=C4=87" <[email protected]><br><b>To: </b>=
"ritesh mahajan" <[email protected]><br><b>Cc: </b>"insig=
ht-users" <[email protected]><br><b>Sent: </b>Tuesday, September =
25, 2018 8:16:52 PM<br><b>Subject: </b>Re: [ITK] [ITK-users] ImageSeriesRea=
der type pointer crashes in debug mode<br></div><div><br></div><div data-ma=
rker=3D"__QUOTED_TEXT__"><div dir=3D"ltr"><div class=3D"gmail_default" styl=
e=3D"font-family: verdana,sans-serif; font-size: small;" data-mce-style=3D"=
font-family: verdana,sans-serif; font-size: small;">Hi Ritesh,</div><div cl=
ass=3D"gmail_default" style=3D"font-family: verdana,sans-serif; font-size: =
small;" data-mce-style=3D"font-family: verdana,sans-serif; font-size: small=
;"><br></div><div class=3D"gmail_default" style=3D"font-family: verdana,san=
s-serif; font-size: small;" data-mce-style=3D"font-family: verdana,sans-ser=
if; font-size: small;">When code crashes in Debug mode, but runs in Release=
or vice versa, it means it has a deficiency (bug) which manifests in one o=
f those modes. As you did not provide the code which uses the reader, I can=
not offer any more specific advice. Providing a <a href=3D"http://sscce.org=
/" target=3D"_blank">runnable</a> example will make it easier for people to=
help you.</div><div class=3D"gmail_default" style=3D"font-family: verdana,=
sans-serif; font-size: small;" data-mce-style=3D"font-family: verdana,sans-=
serif; font-size: small;"><br></div><div class=3D"gmail_default" style=3D"f=
ont-family: verdana,sans-serif; font-size: small;" data-mce-style=3D"font-f=
amily: verdana,sans-serif; font-size: small;"><div class=3D"gmail_default">=
We have transitioned away from this list, to the <a href=3D"https://di=
scourse.itk.org/" target=3D"_blank">forum</a>. Please post your updated que=
stion there, as more people will see it.</div><div class=3D"gmail_default">=
<br></div><div class=3D"gmail_default">Regards,</div><div class=3D"gmail_de=
fault">D=C5=BEenan</div></div></div><br><div class=3D"gmail_quote"><div dir=
=3D"ltr">On Tue, Sep 25, 2018 at 1:45 AM ritesh.mahajan <<a href=3D"mail=
to:[email protected]" target=3D"_blank">[email protected]=
oh.com</a>> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"m=
argin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;" data-mc=
e-style=3D"margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1=
ex;">Hello Team,<br>
<br>
When i am creating a smart pointer globally and allocating the memory to it=
.<br>
In debug mode "it crashes". While when the same code is run in release mode=
<br>
it seems to work fine. Can some one help me out why is it so ?<br>
<br>
Please find the below code:<br>
<br>
typedef signed short PixelType;<br>
typedef itk::Image< PixelType, 3>ImageType;<br>
typedef itk::ImageSeriesReader< ImageType >ReaderType;<br>
ReaderType:: Pointer reader=3D ReaderType::New();<br>
<br>
void ImageRead()<br>
{<br>
// using pointer reader here.<br>
// which is allocated memory at global level<br>
}<br>
<br>
The above code crashes in debug mode<br>
<br>
<br>
<br>
--<br>
Sent from: <a href=3D"http://itk-users.7.n7.nabble.com/" rel=3D"noreferrer"=
target=3D"_blank">http://itk-users.7.n7.nabble.com/</a><br>
The ITK community is transitioning from this mailing list to <a href=3D"htt=
p://discourse.itk.org" rel=3D"noreferrer" target=3D"_blank">discourse.itk.o=
rg</a>. Please join us there!<br>
________________________________<br>
Powered by <a href=3D"http://www.kitware.com" rel=3D"noreferrer" target=3D"=
_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href=3D"http://www.kitware.com/opensource/opensource.html" rel=3D"norefe=
rrer" target=3D"_blank">http://www.kitware.com/opensource/opensource.html</=
a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href=3D"http://www.kitware.com/products/protraining.php" rel=3D"noreferr=
er" target=3D"_blank">http://www.kitware.com/products/protraining.php</a><b=
r>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href=3D"http://www.itk.org/Wiki/ITK_FAQ" rel=3D"noreferrer" target=3D"_b=
lank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href=3D"https://itk.org/mailman/listinfo/insight-users" rel=3D"noreferre=
r" target=3D"_blank">https://itk.org/mailman/listinfo/insight-users</a><br>
The ITK community is transitioning from this mailing list to <a href=3D"htt=
p://discourse.itk.org" rel=3D"noreferrer" target=3D"_blank">discourse.itk.o=
rg</a>. Please join us there!<br>
________________________________________<br>
Community mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">[email protected]</a=
><br>
<a href=3D"https://itk.org/mailman/listinfo/community" rel=3D"noreferrer" t=
arget=3D"_blank">https://itk.org/mailman/listinfo/community</a><br>
</blockquote></div><br></div></div></body></html>
------=_Part_86098_997975555.1537891351774--
--===============0897448687==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php
Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ
Follow this link to subscribe/unsubscribe:
https://itk.org/mailman/listinfo/insight-users
--===============0897448687==--