Boost logo

Boost :

Subject: Re: [boost] [Locale] Static locale initialisation
From: Artyom (artyomtnk_at_[hidden])
Date: 2010-04-11 10:23:10


Hello, > Here is the repro code: http://www.doc.ic.ac.uk/~awl03/locale_test2.zip > > To see the different situations, change which commentted > line declaring > LocaleSetup.  The problem seems to be that > std::has_facet looks for a Facet > with an id of 46 (0x2e).  But when it gets to this > line: > >     const facet *_Facptr = _Id < > _Ptr->_Facetcount >               >    ? _Ptr->_Facetvec[_Id] : 0; // null if > id off end > > _Facetcount is 46 so it decides it's off the end.  I > notice that in the > working version _Facet::id is 44 (0x2c). Till I get to VS at evening so I'll be able to answer. Few questions: 1. Are you using statically or dynamically liked boost.locale? 2. Are you using statically or dynamically liked boost.test? 3. If you use dynamically liked versions do you specify correct import defines? 4. The last what parameters of CMake did you used when you build boost.locale library. 5. I really hope that after build you did not switch Debug/Release from the MSVC project but rather prepared two solutions with passing correct options to CMake? > > Any idea what's happening here? > Yes... This is what called why I love dlls very much ;-) Each facet type should have specific unique id which is static member of facet class (std::locale::id). If this id is not unique - two different ids would be created and thus there would be mismatch of facets and you would not be able to use them. More then that, each time when id is initialized it uses some kind of global counter (static as well) that usually belongs to standard C++ library. If it is not unique two different facets may accidentally have same numeric id and... not work. How could this can happen? If some unit that accesses locale incorrectly uses standard library not importing symbols correctly it would end with duplicate counters or duplicate ids and this is relate to **evey** compilation unit. Also if the code uses accidentally debug and release version of MSVCRTX.dll This may happen. So it is very easy to screw everything up when using dlls and static class members... So what happens something somehow didn't used everything correctly. So you should be extremely careful when creating or using DLLs. At this point I have no idea. Maybe I missed something in my code or there is something missing in the builds. ................ P.S.: That is exactly the reason that after spending lots of time on Linux I suffer very much when I touch everything Windows related. P.P.S.: I'll take a look on the code you gave today or tomorrow. Artyom


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk