Anonymous | Login | 2021-01-17 19:47 MSK | ![]() |
My View | View Issues | Change Log | Roadmap |
View Issue Details [ Jump to Notes ] | [ Issue History ] [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0022808 | Community | [OCCT] OCCT:Foundation Classes | public | 2011-11-21 11:12 | 2013-04-29 15:22 | ||||
Reporter | szy | ||||||||
Assigned To | bugmaster | ||||||||
Priority | normal | Severity | minor | ||||||
Status | closed | Resolution | fixed | ||||||
Platform | A | OS | L | OS Version | L | ||||
Product Version | [OCCT] 6.5.2 | ||||||||
Target Version | [OCCT] 6.6.0 | Fixed in Version | [OCCT] 6.6.0 | ||||||
Summary | 0022808: Undocumented change of global locale | ||||||||
Description | Post from the forum - http://www.opencascade.org/org/forum/thread_22210/. [^] 1."What is the purpose of the line 1549 (void)setlocale(LC_ALL, ""); in Storage_Schema.cxx, Storage_Schema::ICreationDate()? And more important why is the locale not set back, like LC_NUMERIC in the same function? This function gets called everytime I use the OCC save mechanism. This (for me) unrecognized change of the localization messed things up in the rest of my application. As a fix I used the OSD_Localizer to encapsulate my OCC calls and prevent interference with my own localization settings. But I think this should still be considered a bug." 2. " Markus Rhein | reply 2011/11/18 15:49 I don╢t think OSD_Localizer is working as intended. Is it possible that the variable myLocale can get corrupt before restore () gets called? Also I would suggest restoring the original localization settings in the destructor of OSD_Localizer." | ||||||||
Tags | No tags attached. | ||||||||
Test case number | |||||||||
Attached Files | ![]() ![]() | ||||||||
![]() |
|||||||||||
|
![]() |
|
(0019157) barbier (developer) 2012-01-17 18:20 edited on: 2012-01-17 18:22 |
Since dates are created by calling strftime with a locale-independent format, result is independent of user's locale and all calls to setlocale can be dropped (from src/Storage/Storage_Schema.cxx and src/XmlLDrivers/XmlLDrivers.cxx). See drop-setlocale.patch |
(0019160) barbier (developer) 2012-01-17 18:45 |
drop-setlocale2.patch supersedes drop-setlocale.patch, it also removes #include <locale.h> |
(0019213) abv (manager) 2012-01-20 18:31 |
We shall use OSD_Localizer class to set / unset locales throughout the OCCT code. As indicated in discussions on the forums, this class needs to be improved: - Make copy of the string returned by setlocale - Restore locale in destructor (perhaps optionally) - Provide thread-safe work with locales (e.g. using C++ locales as suggested by Denis Barbier, or switching global setting, like _configthreadlocale() in MSVC) |
(0019214) barbier (developer) 2012-01-20 18:47 |
My reluctance against setlocale() is that this function modifies locales for *all* threads. This may be a serious problem in a multithreaded environment, even if original locale is restored afterwards, because OCC code may cause trouble in 3rd party code. This is why I advocated for using C++ locales, one can change locale for a single stream. OTOH it seems that uselocale() is a new POSIX 2008 function which works like setlocale() but only on the current thread. This may be an option, I have no idea how well it is supported. It is in glibc for a long time. You already provided a similar solution on Windows. |
(0023384) kgv (developer) 2013-02-19 12:41 |
Dear bugmaster, this issue was taken into account within 0022898 patch. Please close this bug. |
(0023391) bugmaster (administrator) 2013-02-19 18:47 |
The problem has been corrected by fix for 0022898 issue. |
![]() |
|||
Date Modified | Username | Field | Change |
2011-11-21 11:12 | szy | New Issue | |
2011-11-21 11:12 | szy | Assigned To | => abv |
2012-01-17 16:26 | abv | Relationship added | related to 0022898 |
2012-01-17 18:20 | barbier | Note Added: 0019157 | |
2012-01-17 18:21 | barbier | File Added: drop-setlocale.patch | |
2012-01-17 18:22 | barbier | Note Edited: 0019157 | View Revisions |
2012-01-17 18:44 | barbier | File Added: drop-setlocale2.patch | |
2012-01-17 18:45 | barbier | Note Added: 0019160 | |
2012-01-20 18:31 | abv | Note Added: 0019213 | |
2012-01-20 18:31 | abv | Status | new => assigned |
2012-01-20 18:47 | barbier | Note Added: 0019214 | |
2012-01-30 08:17 | abv | Relationship added | related to 0022933 |
2012-03-22 06:16 | abv | Target Version | 6.5.3 => 6.5.4 |
2012-10-23 19:01 | abv | Target Version | 6.5.4 => 6.6.0 |
2013-02-19 12:41 | kgv | Note Added: 0023384 | |
2013-02-19 12:41 | kgv | Status | assigned => feedback |
2013-02-19 12:41 | kgv | Assigned To | abv => bugmaster |
2013-02-19 18:46 | bugmaster | Status | feedback => tested |
2013-02-19 18:47 | bugmaster | Note Added: 0023391 | |
2013-02-19 18:47 | bugmaster | Status | tested => verified |
2013-02-19 18:47 | bugmaster | Resolution | open => fixed |
2013-04-23 13:36 | aiv | Status | verified => closed |
2013-04-29 15:22 | aiv | Fixed in Version | => 6.6.0 |
Copyright © 2000 - 2021 MantisBT Team |