Discussion:
[ITK-users] ImageSeriesReader type pointer crashes in debug mode
Ritesh Mahajan
2018-09-25 05:34:25 UTC
Permalink
Hello Team,

When i am creating a smart pointer globally and allocating the memory to it. When this is ran in debug mode "it crashes". While when the same code is run in release mode it seems to work fine. Can some one help me out why is it so ?

Please find the below code:

typedef signed short PixelType;
typedef itk::Image< PixelType, 3>ImageType;
typedef itk::ImageSeriesReader< ImageType >ReaderType;
ReaderType:: Pointer reader= ReaderType::New();

void ImageRead()
{
// using pointer reader here.
// which is allocated memory at global level
}

The above code crashes in debug mode.

Thanks,
Ritesh Mahajan
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
ritesh.mahajan
2018-09-25 05:38:05 UTC
Permalink
Hello Team,

When i am creating a smart pointer globally and allocating the memory to it.
In debug mode "it crashes". While when the same code is run in release mode
it seems to work fine. Can some one help me out why is it so ?

Please find the below code:

typedef signed short PixelType;
typedef itk::Image< PixelType, 3>ImageType;
typedef itk::ImageSeriesReader< ImageType >ReaderType;
ReaderType:: Pointer reader= ReaderType::New();

void ImageRead()
{
// using pointer reader here.
// which is allocated memory at global level
}

The above code crashes in debug mode



--
Sent from: http://itk-users.7.n7.nabble.com/
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
Dženan Zukić
2018-09-25 14:46:52 UTC
Permalink
Hi Ritesh,

When code crashes in Debug mode, but runs in Release or vice versa, it
means it has a deficiency (bug) which manifests in one of those modes. As
you did not provide the code which uses the reader, I cannot offer any more
specific advice. Providing a runnable <http://sscce.org/> example will make
it easier for people to help you.

We have transitioned away from this list, to the forum
<https://discourse.itk.org/>. Please post your updated question there, as
more people will see it.

Regards,
DÅŸenan

On Tue, Sep 25, 2018 at 1:45 AM ritesh.mahajan <
Post by Ritesh Mahajan
Hello Team,
When i am creating a smart pointer globally and allocating the memory to it.
In debug mode "it crashes". While when the same code is run in release mode
it seems to work fine. Can some one help me out why is it so ?
typedef signed short PixelType;
typedef itk::Image< PixelType, 3>ImageType;
typedef itk::ImageSeriesReader< ImageType >ReaderType;
ReaderType:: Pointer reader= ReaderType::New();
void ImageRead()
{
// using pointer reader here.
// which is allocated memory at global level
}
The above code crashes in debug mode
--
Sent from: http://itk-users.7.n7.nabble.com/
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
http://www.kitware.com/products/protraining.php
http://www.itk.org/Wiki/ITK_FAQ
https://itk.org/mailman/listinfo/insight-users
The ITK community is transitioning from this mailing list to
discourse.itk.org. Please join us there!
________________________________________
Community mailing list
https://itk.org/mailman/listinfo/community
Ritesh Mahajan
2018-09-25 16:02:31 UTC
Permalink
Thanks for reply. I shared the same issue with forum as well under community category. Please find the below code. This is simple cpp file containing function to read dicom. In which the dicomReader 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< TOutputImage >::ImageSource().

// itk headers
#include "itkGDCMImageIO.h"
#include "itkGDCMSeriesFileNames.h"
#include "itkImageSeriesReader.h"
#include "itkImageSeriesWriter.h"
#include "itksys/SystemTools.hxx"
#include "itkVersion.h"
#include "itkImage.h"
#include "gdcmUIDGenerator.h"
#include "itkFileOutputWindow.h"
#include "DicomReader.hpp"

using namespace std;

typedef signed short PixelType;
typedef itk::Image< PixelType, 3> ImageType;
typedef itk::ImageSeriesReader< ImageType > ReaderType;
typedef itk::GDCMImageIO ImageIOType;
typedef itk::GDCMSeriesFileNames NamesGeneratorType;

ReaderType::Pointer dicomReader= ReaderType::New();

void ParseDicom(const string &dicomDirectory)
{
NamesGeneratorType::Pointer apNamesGenerator = NamesGeneratorType::New();
ImageIOType::Pointer apGdcmIO = ImageIOType::New();

apNamesGenerator->SetInputDirectory(dicomDirectory);

const ReaderType::FileNamesContainer & filenames =
apNamesGenerator->GetInputFileNames();

dicomReader ->SetImageIO(apGdcmIO);
dicomReader ->SetFileNames(filenames);
try
{
dicomReader ->Update();
}
catch (itk::ExceptionObject &excp)
{
std::cerr << "exception in file reader " << std::endl;
throw (excp);
}
}

From: "DÅŸenan Zukić" <***@gmail.com>
To: "ritesh mahajan" <***@ripl.ricoh.com>
Cc: "insight-users" <insight-***@itk.org>
Sent: Tuesday, September 25, 2018 8:16:52 PM
Subject: Re: [ITK] [ITK-users] ImageSeriesReader type pointer crashes in debug mode

Hi Ritesh,

When code crashes in Debug mode, but runs in Release or vice versa, it means it has a deficiency (bug) which manifests in one of those modes. As you did not provide the code which uses the reader, I cannot offer any more specific advice. Providing a runnable example will make it easier for people to help you.

We have transitioned away from this list, to the forum . Please post your updated question there, as more people will see it.

Regards,
DÅŸenan

On Tue, Sep 25, 2018 at 1:45 AM ritesh.mahajan < ***@ripl.ricoh.com > wrote:


Hello Team,

When i am creating a smart pointer globally and allocating the memory to it.
In debug mode "it crashes". While when the same code is run in release mode
it seems to work fine. Can some one help me out why is it so ?

Please find the below code:

typedef signed short PixelType;
typedef itk::Image< PixelType, 3>ImageType;
typedef itk::ImageSeriesReader< ImageType >ReaderType;
ReaderType:: Pointer reader= ReaderType::New();

void ImageRead()
{
// using pointer reader here.
// which is allocated memory at global level
}

The above code crashes in debug mode
--
Sent from: http://itk-users.7.n7.nabble.com/
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
The ITK community is transitioning from this mailing list to discourse.itk.org . Please join us there!
________________________________________
Community mailing list
***@itk.org
https://itk.org/mailman/listinfo/community
Loading...