[Qt-interest] Application crashing on Win32/Qt4.4.3
Alan M. Carroll
amc at network-geographics.com
Tue Feb 17 01:35:49 CET 2009
That's not strictly true. MSVC, as per the C++ standard, guarantees in order initialization for statics *in the same translation unit*. Except for truly esoteric situations, that means the same source file. If you have all of your statics in one file (my habit) then you can count on them being initialized in the order they appear in the file. It is the ordering of initialization of the translation units that is indeterminate. Sadly, that is conformant with the C++ language specification.
Under UNIX style linkers (e.g., Linux) the translation units will be initialized in the order of linkage (or reverse order, it's been a while). Therefore a bit of work with the link command line solves the problem. MSVC provides no direct way to do this, which I think is bizarre given that an MSVC project already has the information necessary to handle it automatically. However, if you are determined, it is doable. Drop me an email if that's a swamp you want to wade in, I won't clutter the list with the details.
I do agree with Tony that this problem definitely smells of initialization order issues.
At 05:56 PM 2/16/2009, Tony Rietwyk wrote:
><snip>
>
>> ../Qt/4.4.3/include/QtCore/../../src/
>> corelib/tools/qstringlist.h:82 #5 0x0041068b in
>> __static_initialization_and_destruction_0(int, int)
>> ( __initialize_p=1, __priority=65535) at src/ui/cellfield.cc:39 #6
>
>
>Hi Vladimir,
>
>I'm not sure about Mac or Linux, but on Windows with Visual Studio, you
>cannot assume the order of initialisation of any global objects. In this
>case, the strings may not have been initialised yet.
More information about the Qt-interest-old
mailing list