[prev in list] [next in list] [prev in thread] [next in thread] 

List:       vtkusers
Subject:    Re: [vtkusers] 5.0 vtk crash with /MT build on windows
From:       "David Cole" <david.cole () kitware ! com>
Date:       2007-11-29 22:32:11
Message-ID: f435c2c50711291432p5c7ca073x4f40b5d9761bb895 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Usually this means that the "new" was performed with either (1) the
statically linked in MSVC runtime libraries or (2) the dll version of MSVCRT
and the "delete" is being performed by the other one. This sort of mismatch
will almost always eventually lead to a heap corruption.

All of your components that do cross-component new/delete operations have to
be linked to the same flavor (static or dll) or the MSVC runtime libraries.

Are you sure that *everything* is compiled with /MT??

I would try starting again with a clean binary directory to ensure that /MT
is actually used to compile *everything*. Then, also make sure there are no
other versions of VTK dll's in your PATH environment variable.

If it still happens after that, we can continue discussing other ways to
figure out why this might be happening for you..... It should work.


HTH,
David


On 11/14/07, hu ning <nickhuning@hotmail.com> wrote:
>
>  Hi,
>
> I wonder if anyone here has experienced this kind of problem and could
> give me some advice: I have to build the vtk 5.0.3 shared libraries with
> /MT instead of /MD on VC++ 8, then every time when my application start
> initializing vtkRenderWindow it crashes. I am able to find in the class
> vtkOpenGLRenderWindow:
> vtkOpenGLRenderWindow::vtkOpenGLRenderWindow()
> {
>         this->MultiSamples =
> vtkOpenGLRenderWindowGlobalMaximumNumberOfMultiSamples;
>          this->TextureResourceIds = vtkIdList::New();
>           if ( this->WindowName )
>                 delete [] this->WindowName; ########## crash here
>           this->WindowName = new char[strlen("Visualization Toolkit -
> OpenGL")+1];
>                 strcpy( this->WindowName, "Visualization Toolkit - OpenGL"
> );
> }
>
> when it try to delete [] this->WindowName, there is memory corruption. I
> checked the content in the this->WindowName and it seems correct.
>
> I also tested with the same vtk version with /MD build which is default
> setting, and it runs ok. The reason I need to have /MT because all the
> components in my app are built with /MT. The previous release of vtk, 4.2,
> doesn't have this problem.
>
> Any discussion/advice will be highly appreciated!
>
> Thank you,
>
> Nick
>
> ------------------------------
> Are you ready for Windows Live Messenger Beta 8.5 ? Get the latest for
> free today! <http://entertainment.sympatico.msn.ca/WindowsLiveMessenger>
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>

[Attachment #5 (text/html)]

Usually this means that the &quot;new&quot; was performed with either (1) the \
statically linked in MSVC runtime libraries or (2) the dll version of MSVCRT and the \
&quot;delete&quot; is being performed by the other one. This sort of mismatch will \
almost always eventually lead to a heap corruption. <br><br>All of your components \
that do cross-component new/delete operations have to be linked to the same flavor \
(static or dll) or the MSVC runtime libraries.<br><br>Are you sure that *everything* \
is compiled with /MT?? <br><br>I would try starting again with a clean binary \
directory to ensure that /MT is actually used to compile *everything*. Then, also \
make sure there are no other versions of VTK dll&#39;s in your PATH environment \
variable. <br><br>If it still happens after that, we can continue discussing other \
ways to figure out why this might be happening for you..... It should \
work.<br><br><br>HTH,<br>David<br><br><br><div><span class="gmail_quote">On 11/14/07, \
 <b class="gmail_sendername">hu ning</b> &lt;<a \
href="mailto:nickhuning@hotmail.com">nickhuning@hotmail.com</a>&gt; \
wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, \
204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">




<div>
Hi,<br><br>I wonder if anyone here has experienced this kind of problem and could \
give me some advice: I have to build the vtk 5.0.3 shared libraries with /MT instead \
of /MD on VC++ 8, then every time when my application start initializing \
vtkRenderWindow it crashes. I am able to find in the class vtkOpenGLRenderWindow: \
<br>vtkOpenGLRenderWindow::vtkOpenGLRenderWindow()<br>{<br>&nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; this-&gt;MultiSamples = \
vtkOpenGLRenderWindowGlobalMaximumNumberOfMultiSamples;<br>&nbsp; &nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; this-&gt;TextureResourceIds = vtkIdList::New();<br>&nbsp; \
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if ( this-&gt;WindowName )  \
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
delete [] this-&gt;WindowName; ########## crash here<br>&nbsp; &nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; this-&gt;WindowName = new char[strlen(&quot;Visualization Toolkit \
- OpenGL&quot;)+1];<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
&nbsp;&nbsp;&nbsp; strcpy( this-&gt;WindowName, &quot;Visualization Toolkit - \
OpenGL&quot; ); <br>}<br><br>when it try to delete [] this-&gt;WindowName, there is \
memory corruption. I checked the content in the this-&gt;WindowName and it seems \
correct.<br><br>I also tested with the same vtk version with /MD build which is \
default setting, and it runs ok. The reason I need to have /MT because all the \
components in my app are built with /MT. The previous release of vtk,  4.2, \
doesn&#39;t have this problem.<br><br>Any discussion/advice will be highly \
appreciated!<br><br>Thank you,<br><br>Nick<br><br><hr>Are you ready for Windows Live \
Messenger Beta 8.5 ? <a \
href="http://entertainment.sympatico.msn.ca/WindowsLiveMessenger" target="_blank" \
onclick="return top.js.OpenExtLink(window,event,this)"> Get the latest for free \
today!</a></div> <br>_______________________________________________<br>This is the \
private VTK discussion list.<br>Please keep messages on-topic. Check the FAQ at: <a \
onclick="return top.js.OpenExtLink(window,event,this)" \
href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank"> \
http://www.vtk.org/Wiki/VTK_FAQ</a><br>Follow this link to \
subscribe/unsubscribe:<br><a onclick="return top.js.OpenExtLink(window,event,this)" \
href="http://www.vtk.org/mailman/listinfo/vtkusers" \
target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers \
</a><br><br></blockquote></div><br>



_______________________________________________
This is the private VTK discussion list. 
Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic