Good news: this bug is now fixed. PI version 1.7.0.696 for Windows will be released as a regular update this evening.
Information for developersJust for the fun of it, here is a description of this bug. Although it seems an easy one (and it's easy to fix actually), finding it has been quite difficult.
Code excerpted from pcl/ImageVariant.h:
137: class PCL_CLASS ImageVariant
138: {
139: public:
140:
141: typedef AbstractImage::color_space color_space;
142:
143: /*!
144: Constructs an %ImageVariant instance that does not transport an image.
145: */
146: ImageVariant() : data( new Data )
147: #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
148: , shared( 0 )
149: #endif
150: {
151: }
152:
// ...
There's nothing fancy here: just a default constructor for class pcl::ImageVariant. The __PCL_BUILDING_PIXINSIGHT_APPLICATION macro is defined, as its name clearly says, only when we are building the PixInsight Core application. Hence, the shared data member (a pointer) only exists within the core application, and is initialized to zero by the constructor in line #148. Again, nothing too complex; just a data pointer correctly initialized.
The problem is that Visual C++ 2010 x64 ignores the code in line 148 completely. There is no way to convince it that this line must be compiled, including all sorts of permutations of punctuators and whitespace characters. Nothing is generated for 'shared( 0 )'. Putting a sentence like 'shared = 0;' in the constructor's body does not help either; VC++ 2010 x64 ignores it for some exotic reason. So the shared data member is never initialized on Windows x64 when an ImageVariant instance is constructed. This has no practical consequences within the core application, but a few modules that load images dynamically lead to access violation errors when they try to use PCL's shared image mechanisms.
The solution to this bug is relatively straightforward. I have added this declaration to the ImageVariant class:
1020: #ifdef __PCL_BUILDING_PIXINSIGHT_APPLICATION
// ...
1035: /*
1036: * Workaround to Visual C++ compiler error ('shared' member not initialized)
1037: */
1038: # ifdef __PCL_WINDOWS
1039: static ImageVariant* NewImageVariant();
1040: # endif
1041:
1042: #endif
whose implementation is as simple as:
34: #ifdef __PCL_WINDOWS
35: ImageVariant* ImageVariant::NewImageVariant()
36: {
37: ImageVariant* v = new ImageVariant;
38: v->shared = 0;
39: return v;
40: }
41: #endif
This forces initialization of the shared data member to zero (and luckily VC++ compiles it!). Then, each time a new ImageVariant is dynamically created in the PI Core application we have:
#ifdef __PCL_WINDOWS
ImageVariant* img = ImageVariant::NewImageVariant();
#else
ImageVariant* img = new ImageVariant;
#endif
I want to stress the fact that this problem does not happen on any platform except Windows x64. This includes 32-bit Windows, where the original code works perfectly. I have made no distinctions between Win64 and Win32 however, just to stay on the safe side.
There is another bug that I have also fixed, and it is also a VC++ compiler bug. I'll describe it later.
End of the story
![smile :)](http://pixinsight.com/forum/Smileys/default/smile.gif)