[vtkusers] ActiViz 5.8.0 recurring random AccessViolationException

Duperthuy, Christophe Christophe.Duperthuy at bioclinica.com
Thu Sep 11 03:45:34 EDT 2014


Dear VTK  ActiViz users,
We are working on a x64 C# WinForm application based on Activiz 5.8.0 wrapping of VTK classes.
Since migration of our application to Framework .NET4.0 (we were previously building with .NET3.5) it appears that we experience more frequent random crashes related to the Activiz wrapping.
The crashing methods die with an AccessViolationException which generally occurs within one the 4 following methods (though we can find other less recurrent places):

*         Kitware.VTK.vtkRenderWindow.vtkRenderWindow_Render_88 (usually on mouse event)

*         Kitware.VTK.vtkAlgorithm.vtkAlgorithm_UpdateWholeExtent_73 (usually on mouse event)

*         Kitware.VTK.vtkDataObject.vtkDataObject_UnRegister_120 (finalizer)

*         Kitware.VTK. vtkObjectBase.vtkObjectBase_UnRegister_12 (finalizer)
I read from < http://vtkdotnet.sourceforge.net/Programming.html> (last paragraph) that such crashes could be related to bad referencing or bad event un-subscription.
If I reduce the C# code to the following one in a C# Console application, in Release x64 (x86 with pending x86 Activiz dlls crashes the same), I experience the crash randomness, principally in the GC Finalizer Thread for method vtkDataObject_UnRegister_120, but also in the main thread at the update (vtkAlgorithm_Update_68 in this case)
namespace VTKCrashTestApplication
{
    using System;
    using System.Threading;
    using Kitware.VTK;

    // to add Kitware.Activiz.dll and Kitware.mummy.Runtime.dll to your References

    // to add to PostBuild replacing <LibraryFolderPath> with your own path
    //xcopy "<LibraryFolderPath>\Activiz\5.8.0\$(PlatformName)\*.*" $(ProjectDir)$(OutDir) /i /y

    internal class Program
    {
        private static void Main(string[] args)
        {
            Thread lGCStressThread = new Thread(GarbageCollectorStressThread);
            lGCStressThread.Start();

            // just a time feedback
            Console.WriteLine(string.Format("Start time: {0}", DateTime.Now));

            // create the unique source instance
            vtkSphereSource lVtkSphereSource = vtkSphereSource.New();
            int count = 0;

            while (true)
            {
                // update the source
                lVtkSphereSource.SetRadius(1 + count%100);
                lVtkSphereSource.Update();

                // get a volatile reference to the source output
                vtkPolyData lvtkPolyData = lVtkSphereSource.GetOutput();
                count++;
            }
        }

        private static void GarbageCollectorStressThread(object arg)
        {
            int gccount = 0;
            while (true)
            {
                GC.Collect();
                Thread.Sleep(200);
                GC.WaitForPendingFinalizers();
                gccount++;
            }
        }
    }
}

As we've tried to dig into the vtkusers mailing list, we barely read answers to the posts.
I plan to build a Debug version of the wrappers, to get a better understanding of what's going on. As for now, I can hardly get it working for 5.8.0 (Debug x64)...
Any constructive feedback will be appreciated.
/chris
-- Confidentiality Notice: This e-mail transmission may contain confidential or legally privileged information that is intended only for the individual or entity named in the e-mail address. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or reliance upon the contents of this e-mail is strictly prohibited. If you have received this e-mail transmission in error, please reply to the sender and then delete the message from your computer. Thank you. -- Confidentiality Notice: This e-mail transmission may contain confidential or legally privileged information that is intended only for the individual or entity named in the e-mail address. If you are not the intended recipient, you are hereby notified that any disclosure, copying, distribution, or reliance upon the contents of this e-mail is strictly prohibited. If you have received this e-mail transmission in error, please reply to the sender and then delete the message from your computer. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20140911/834418c3/attachment.html>


More information about the vtkusers mailing list