-
Notifications
You must be signed in to change notification settings - Fork 430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OCIO fails parsing configs with non-C locale #297
Comments
Also observed on OS X, with a French locale (fr_FR.UTF-8). |
- setlocale(LC_ALL,"C") doesn’t seem to affect LC_NUMERIC if the LC_NUMERIC environment variable is detained (as in Ubuntu 14.04LTS) - issue AcademySoftwareFoundation/OpenColorIO#297 requires proper numeric locale setting - fixes #67 (hopefully)
This problem has also been reported several times in appleseed: |
I just got bit by this when writing a plugin for 3ds Max that uses OCIO. |
I went through this a year or two ago with OpenImageIO. I had to ruthlessly find all printf, scanf, and iostream stuff and replace it all with a new set of calls that I guarantee to be locale-independent. |
An alternative to changing the calls is to fix the locale around the call. We fixed this specific OCIO issue on the host side by saving the thread locale, setting it to "C" locale, calling the OCIO function, and then restoring the locale. It's all wrapped in an auto-style C++ class, so it's one line of code in the places we needed it. Yes, I reported it at the time, but we needed a fix ASAP so that's how we did it. I recall it was a beautiful looking bug -- if you were running French language OS, one of our color managed looks got all posterized. It turned out to be because the LUT read only got integers instead of floating-point numbers (because decimal separator in French is not "."), so the curve because stair-steps. |
Oh we got that one at Duran Dubois when compiling Qt for Maya. All the
artists got Minecraft like assets as everything was rounded to next
integer. The panic it caused was unbelievable :)
…On Wed, 26 Jun 2019, 06:19 Dithermaster, ***@***.***> wrote:
An alternative to changing the calls is to fix the locale around the call.
We fixed this specific OCIO issue on the host side by saving the thread
locale, setting it to "C" locale, calling the OCIO function, and then
restoring the locale. It's all wrapped in an auto-style C++ class, so it's
one line of code in the places we needed it. Yes, I reported it at the
time, but we needed a fix ASAP so that's how we did it.
I recall it was a beautiful looking bug -- if you were running French
language OS, one of our color managed looks got all posterized. It turned
out to be because the LUT read only got integers instead of floating-point
numbers (because decimal separator in French is not "."), so the curve
because stair-steps.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#297>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAYLQ4766A5RUADV2YUQQ3P4JOS3ANCNFSM4ACPFBWA>
.
|
What bugs me is that I spent a long time trying to figure out what was wrong. But after I found out it was locale, the fix was easy in the host (3ds Max in this case). // OCIO has a , vs . bug depending on system locale
// https://github.com/imageworks/OpenColorIO/issues/297
const char* curlocale = strdup(setlocale(LC_NUMERIC, NULL)); // save current numeric locale
setlocale(LC_NUMERIC, "C"); // set numeric locale to C
// Put your affected OCIO code here
processor = config->getProcessor(transform);
setlocale(LC_NUMERIC, curlocale); // restore numeric locale It's a very manual approach but it was quick. So I would love to see how @Dithermaster solved it :) |
Our solution was based on the same APIs, but wrapped in C++ and with Windows support:
and
Then in a block where you're making OCIO calls, have |
This commit brings in the amalgamated header of the fast_float library, and applies it to our uses of sscanf with %f. This library is locale-free, and does not incur the performance penalty of using a thread locale RAII class. Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1022
This commit brings in the amalgamated header of the fast_float library, and applies it to our uses of sscanf with %f. This library is locale-free, and does not incur the performance penalty of using a thread locale RAII class. Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1022 Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit brings in the amalgamated header of the fast_float library, and applies it to our uses of sscanf with %f. This library is locale-free, and does not incur the performance penalty of using a thread locale RAII class. Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1022 Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit brings in the amalgamated header of the fast_float library, and applies it to our uses of sscanf with %f. This library is locale-free, and does not incur the performance penalty of using a thread locale RAII class. Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1322 Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds Daniel Lemire's fast_float library as an external dependency, and applies it to our uses of sscanf with %f as well as istringstream. This library is locale-free, and does not incur the performance penalty of using a thread locale RAII class or imbuing a locale into a stringstream. See: Daniel Lemire, Number Parsing at a Gigabyte per Second, Software: Pratice and Experience 51 (8), 2021. <https://arxiv.org/abs/2101.11408> Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1322 Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds Daniel Lemire's fast_float library as an external dependency, and applies it to our uses of sscanf with %f as well as istringstream. This library is locale-free, and does not incur the performance penalty of using a thread locale RAII class or imbuing a locale into a stringstream. See: Daniel Lemire, Number Parsing at a Gigabyte per Second, Software: Pratice and Experience 51 (8), 2021. <https://arxiv.org/abs/2101.11408> Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1322 Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds Daniel Lemire's fast_float library as an external dependency, and applies it to our uses of sscanf with %f, strtod, and istringstream. Additionally, for parsing integer numbers, we implement a from_chars shim that forwards the call to strtol_l along with a statically initialized locale constant. The usage of fast_float is warded by a new OCIO_USE_FAST_FLOAT configuration variable; if disabled, an identical approach to integers is followed. See: Daniel Lemire, Number Parsing at a Gigabyte per Second, Software: Pratice and Experience 51 (8), 2021. <https://arxiv.org/abs/2101.11408> Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1322 Co-Authored-By: Patrick Hodoul <Patrick.Hodoul@autodesk.com> Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds Daniel Lemire's fast_float library as an external dependency, and applies it to our uses of sscanf with %f, strtod, and istringstream. Additionally, for parsing integer numbers, we implement a from_chars shim that forwards the call to strtol_l along with a statically initialized locale constant. The usage of fast_float is warded by a new OCIO_USE_FAST_FLOAT configuration variable; if disabled, an identical approach to integers is followed. See: Daniel Lemire, Number Parsing at a Gigabyte per Second, Software: Pratice and Experience 51 (8), 2021. <https://arxiv.org/abs/2101.11408> Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1322 Co-Authored-By: Patrick Hodoul <Patrick.Hodoul@autodesk.com> Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds Daniel Lemire's fast_float library as an external dependency, and applies it to our uses of sscanf with %f, strtod, and istringstream. Additionally, for parsing integer numbers, we implement a from_chars shim that forwards the call to strtol_l along with a statically initialized locale constant. The usage of fast_float is warded by a new OCIO_USE_FAST_FLOAT configuration variable; if disabled, an identical approach to integers is followed. See: Daniel Lemire, Number Parsing at a Gigabyte per Second, Software: Pratice and Experience 51 (8), 2021. <https://arxiv.org/abs/2101.11408> Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1322 Co-Authored-By: Patrick Hodoul <Patrick.Hodoul@autodesk.com> Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds Daniel Lemire's fast_float library as an external dependency, and applies it to our uses of sscanf with %f, strtod, and istringstream. Additionally, for parsing integer numbers, we implement a from_chars shim that forwards the call to strtol_l along with a statically initialized locale constant. The usage of fast_float is warded by a new OCIO_USE_FAST_FLOAT configuration variable; if disabled, an identical approach to integers is followed. See: Daniel Lemire, Number Parsing at a Gigabyte per Second, Software: Pratice and Experience 51 (8), 2021. <https://arxiv.org/abs/2101.11408> Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1322 Co-Authored-By: Patrick Hodoul <Patrick.Hodoul@autodesk.com> Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds Daniel Lemire's fast_float library as an external dependency, and applies it to our uses of sscanf with %f as well as istringstream. This library is locale-free, and does not incur the performance penalty of using a thread locale RAII class or imbuing a locale into a stringstream. See: Daniel Lemire, Number Parsing at a Gigabyte per Second, Software: Pratice and Experience 51 (8), 2021. <https://arxiv.org/abs/2101.11408> Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1322 Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds Daniel Lemire's fast_float library as an external dependency, and applies it to our uses of sscanf with %f, strtod, and istringstream. Additionally, for parsing integer numbers, we implement a from_chars shim that forwards the call to strtol_l along with a statically initialized locale constant. Unfortunately, to preserve consistency with from_chars the character range must be copied to a temporary std::string. The test suite has been adapted to account for this new behaviour. The usage of fast_float is warded by a new OCIO_USE_FAST_FLOAT configuration variable; if disabled, an identical approach to integers is followed. See: Daniel Lemire, Number Parsing at a Gigabyte per Second, Software: Pratice and Experience 51 (8), 2021. <https://arxiv.org/abs/2101.11408> Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1322 Co-Authored-By: Patrick Hodoul <Patrick.Hodoul@autodesk.com> Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds Daniel Lemire's fast_float library as an external dependency, and applies it to our uses of sscanf with %f, strtod, and istringstream. Additionally, for parsing integer numbers, we implement a from_chars shim that forwards the call to strtol_l along with a statically initialized locale constant. Unfortunately, to preserve consistency with from_chars the character range must be copied to a temporary std::string. The test suite has been adapted to account for this new behaviour. The usage of fast_float is warded by a new OCIO_USE_FAST_FLOAT configuration variable; if disabled, an identical approach to integers is followed. See: Daniel Lemire, Number Parsing at a Gigabyte per Second, Software: Pratice and Experience 51 (8), 2021. <https://arxiv.org/abs/2101.11408> Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1322 Co-Authored-By: Patrick Hodoul <Patrick.Hodoul@autodesk.com> Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds support for parsing numbers without being influenced by the current system locale. We implement a from_chars shim that forwards the call to strto*_l along with a statically initialized locale constant. Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1322 Co-Authored-By: Patrick Hodoul <Patrick.Hodoul@autodesk.com> Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds support for parsing numbers without being influenced by the current system locale. We implement a from_chars shim that forwards the call to strto*_l along with a statically initialized locale constant. Fixes AcademySoftwareFoundation#297 Fixes AcademySoftwareFoundation#379 Fixes AcademySoftwareFoundation#1322 Co-Authored-By: Patrick Hodoul <Patrick.Hodoul@autodesk.com> Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds support for parsing numbers without being influenced by the current system locale. We implement a from_chars shim that forwards the call to strto*_l along with a statically initialized locale constant. Fixes #297 Fixes #379 Fixes #1322 Co-Authored-By: Patrick Hodoul <Patrick.Hodoul@autodesk.com> Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds support for parsing numbers without being influenced by the current system locale. We implement a from_chars shim that forwards the call to strto*_l along with a statically initialized locale constant. Fixes #297 Fixes #379 Fixes #1322 Co-Authored-By: Patrick Hodoul <Patrick.Hodoul@autodesk.com> Signed-off-by: L. E. Segovia <13498015+amyspark@users.noreply.github.com>
This commit adds support for parsing numbers without being influenced by the current system locale. We implement a from_chars shim that forwards the call to strto*_l along with a statically initialized locale constant. Fixes #297 Fixes #379 Fixes #1322 Co-Authored-By: Patrick Hodoul <Patrick.Hodoul@autodesk.com> Signed-off-by: amyspark <13498015+amyspark@users.noreply.github.com>
This commit adds support for parsing numbers without being influenced by the current system locale. We implement a from_chars shim that forwards the call to strto*_l along with a statically initialized locale constant. Fixes #297 Fixes #379 Fixes #1322 Co-Authored-By: Patrick Hodoul <Patrick.Hodoul@autodesk.com> Signed-off-by: amyspark <13498015+amyspark@users.noreply.github.com> Co-authored-by: amyspark <13498015+amyspark@users.noreply.github.com>
When OCIO is run on a Ubuntu 12.04 machine with a German locale, parsing of srgb.spi1d fails and we get an "Invalid 'From' Tag" exception. The issue is sscanf() there is attempting to parse the string using the German locale.
This should be fixed inside OCIO, the external user should not have to mess with locales before using.
See this thread on ocio-dev for additional information:
http://groups.google.com/forum/?fromgroups=#!topic/ocio-dev/xH47bLSIgwE
The text was updated successfully, but these errors were encountered: