[vtk-developers] Crashes after recent checkins

Berk Geveci berk.geveci at kitware.com
Mon Aug 26 15:02:44 EDT 2013


A few lines above that comment says:

  // Note that this would not normally be thread safe. However,
  // VTK initializes static objects at load time, which in turn call
  // this functions, which make this thread safe. If this behavior
  // changes, this should also be fixed by converting it to a static
  // class member which is initialized at load time.

That code gets called for the first time at library load time, which by
definition would have to be done in a single thread. I would normally move
it directly into library load time by using a static but then I run into
initialization order issues. Actually, I realized that I can guarantee that
it would get called at library load time. A fix coming shortly.

-berk



On Mon, Aug 26, 2013 at 1:29 PM, Brad King <brad.king at kitware.com> wrote:

> On 08/26/2013 12:05 PM, Berk Geveci wrote:
> > Can you try this?
>
> From the patch:
>
> +  if (!vtkTimeStamp::GlobalTimeStamp)
> +    {
> +#if VTK_SIZEOF_VOID_P == 8
> +    vtkTimeStamp::GlobalTimeStamp = new vtkAtomicInt64;
>
> This runtime initialization is not thread-safe, which IIUC
> is the entire point of using an atomic integer.  We can
> achieve proper static initialization and finalization using
> the same Schwarz Counter idiom:
>
>  http://en.wikibooks.org/wiki/More_C++_Idioms/Nifty_Counter
>
> that we already use in several places.  It provides a way
> to order things across translation units.
>
> -Brad
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20130826/41c9e967/attachment.html>


More information about the vtk-developers mailing list