[vtkusers] App crashes unless compiled with debug config (Windows)
Oliver Cairncross
op.cairncross at gmail.com
Sat Sep 3 04:29:24 EDT 2016
yeah target array is fine.
On 3 September 2016 at 17:27, Mike Chinander <chinander at gmail.com> wrote:
>
> Has targetArray been initialized? If not, your program is crashing before
> it even tries to execute your loop body the first time.
>
> On Sep 3, 2016 1:54 AM, "Oliver Cairncross" <op.cairncross at gmail.com>
> wrote:
>
> >
>
> > >
>
> > It will crash when i = 0
> >
> >
> > On 3 Sep 2016 16:10, "Mike Chinander" <chinander at gmail.com> wrote:
>
> >
>
> > >>
>
> >> Is the end condition of your for loop correct? That's the only place
> targetArray appears.
> >>
> >>
> >> On Sep 3, 2016 12:49 AM, "Oliver Cairncross" <op.cairncross at gmail.com>
> wrote:
>
> >
>
> > >>>
>
> >>> (Oh sorry I'll copy it down)
> >>>
> >>> What I'm doing is pretty straight forward. I haven't changed the vtk
> code at all.
> >>>
> >>> vtkDirectory * sourceDir = vtkDirectory::New();
> >>> sourceDir->Open(sourceString.c_str());
> >>> vtkSortFileNames * sourceFiles = vtkSortFileNames::New();
> >>> sourceFiles->SkipDirectoriesOn();
> >>> sourceFiles->NumericSortOff();
> >>> sourceFiles->SetInputFileNames(sourceDir->GetFiles());
> >>> sourceFiles->Update();
> >>>
> >>> for (int i = 0; i < targetArray->GetNumberOfValues(); i++)
> >>> {
> >>> string s1 = sourceFiles->GetFileNames()->GetValue(i); // crash!
> >>> }
> >>>
> >>> Thanks
> >>> Ollie
> >>>
> >>> On 3 September 2016 at 00:02, David E DeMarle <
> dave.demarle at kitware.com> wrote:
>
> >
>
> > >>>>
>
> >>>> You forgot to reply all to keep the discussion on the mailing list
> for posterity.
> >>>>
> >>>> David E DeMarle
> >>>> Kitware, Inc.
> >>>> R&D Engineer
> >>>> 21 Corporate Drive
> >>>> Clifton Park, NY 12065-8662
> >>>> Phone: 518-881-4909
> >>>>
> >>>> On Fri, Sep 2, 2016 at 2:17 AM, Oliver Cairncross <
> op.cairncross at gmail.com> wrote:
>
> >
>
> > >>>>>
>
> >>>>> What I'm doing is pretty straight forward. I haven't changed the vtk
> code at all.
> >>>>>
> >>>>> vtkDirectory * sourceDir = vtkDirectory::New();
> >>>>> sourceDir->Open(sourceString.c_str());
> >>>>> vtkSortFileNames * sourceFiles = vtkSortFileNames::New();
> >>>>> sourceFiles->SkipDirectoriesOn();
> >>>>> sourceFiles->NumericSortOff();
> >>>>> sourceFiles->SetInputFileNames(sourceDir->GetFiles());
> >>>>> sourceFiles->Update();
> >>>>>
> >>>>> for (int i = 0; i < targetArray->GetNumberOfValues(); i++)
> >>>>> {
> >>>>> string s1 = sourceFiles->GetFileNames()->GetValue(i); // crash!
> >>>>> }
> >>>>>
> >>>>> Thanks
> >>>>> Ollie
> >>>>>
> >>>>> On 2 September 2016 at 13:45, David E DeMarle <
> dave.demarle at kitware.com> wrote:
>
> >
>
> > >>>>>>
>
> >>>>>> Whatever your sourceFiles->GetFileNames object has uninitialized
> pointers.
> >>>>>>
> >>>>>> Debug mode initializes all values to 0, release does not (in order
> to save run time), but this leaves you with some pointer pointing to
> nonsense.
> >>>>>>
> >>>>>>
> >>>>>>
> >>>>>> David E DeMarle
> >>>>>> Kitware, Inc.
> >>>>>> R&D Engineer
> >>>>>> 21 Corporate Drive
> >>>>>> Clifton Park, NY 12065-8662
> >>>>>> Phone: 518-881-4909
> >>>>>>
> >>>>>> On Thu, Sep 1, 2016 at 11:32 PM, Oliver Cairncross <
> op.cairncross at gmail.com> wrote:
>
> >
>
> > >>>>>>>
>
> >>>>>>> Hi,
> >>>>>>>
> >>>>>>> vtk 7, msvc 14, windows 10
> >>>>>>>
> >>>>>>> I've had this problem before and thought it was something bad in
> my tool chain. But I've rebuild everything from scratch and it's still a
> problem.
> >>>>>>>
> >>>>>>> If I do something simple like
> >>>>>>>
> >>>>>>> string s1 = sourceFiles->GetFileNames()->GetValue(i);
> >>>>>>>
> >>>>>>> it runs fine in debug mode. When I compile in RelwithDebInfo it
> crashes with a bad allocation.
> >>>>>>> When I have a look at the object the there is garbage where the
> string is supposed to be. As if it hasn't been initialised. I am calling an
> sourceFiles->Update() beforehand.
> >>>>>>>
> >>>>>>> Interestingly if I do
> >>>>>>>
> >>>>>>> cout << sourceFiles->GetFileNames()->GetValue(i);
> >>>>>>> string s1 = sourceFiles->GetFileNames()->GetValue(i);
> >>>>>>>
> >>>>>>> it will print to console and then crash on the next line.
> >>>>>>>
> >>>>>>> Is anyone else having this problem?
> >>>>>>>
> >>>>>>> Cheers
> >>>>>>> ollie
> >>>>>>>
> >>>>>>> _______________________________________________
> >>>>>>> Powered by www.kitware.com
> >>>>>>>
> >>>>>>> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
> >>>>>>>
> >>>>>>> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> >>>>>>>
> >>>>>>> Search the list archives at: http://markmail.org/search/?q=
> vtkusers
> >>>>>>>
> >>>>>>> Follow this link to subscribe/unsubscribe:
> >>>>>>> http://public.kitware.com/mailman/listinfo/vtkusers
> <http://public.kitware.com/mailman/listinfo/vtkusers>
> >>>>>>>
> >>>>>>
> >>>>>
> >>>>
> >>>
> >>>
> >>> _______________________________________________
> >>> Powered by www.kitware.com
> >>>
> >>> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
> >>>
> >>> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> >>>
> >>> Search the list archives at: http://markmail.org/search/?q=vtkusers
> >>>
> >>> Follow this link to subscribe/unsubscribe:
> >>> http://public.kitware.com/mailman/listinfo/vtkusers
> <http://public.kitware.com/mailman/listinfo/vtkusers>
> >>>
> >>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20160903/9173c20f/attachment.html>
More information about the vtkusers
mailing list