-
-
Notifications
You must be signed in to change notification settings - Fork 754
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
ICU-20558 Fix compat issue with DateTimePatternGenerator fallback to default root locale #632
ICU-20558 Fix compat issue with DateTimePatternGenerator fallback to default root locale #632
Conversation
FYI for @tarekgh. |
Thanks @jefgen for tagging me to the issue. could you please confirm this fix will fix the scenario mentioned in https://unicode-org.atlassian.net/browse/ICU-20558 when usign LANG=C.UTF-8? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but it's a nit comment due to my unfamiliarity with code style
FYI: @tarekgh with the change in this PR, the following code snippet now succeeds with #include <stdio.h>
#include "unicode/udatpg.h"
int main()
{
UErrorCode er = U_ZERO_ERROR;
UDateTimePatternGenerator* pGenerator = udatpg_open("C", &er);
UChar monthDayPattern[100];
const UChar UDAT_MONTH_DAY_UCHAR[] = {'M', 'M', 'M', 'M', 'd', '\0'};
udatpg_getBestPattern(pGenerator, UDAT_MONTH_DAY_UCHAR, -1, monthDayPattern, 100, &er);
udatpg_close(pGenerator);
printf("udatpg_getBestPattern returns %d -- %s \n", er, u_errorName(er));
return 0;
} Running the code:
Output:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm that this fixed the crasher nodejs/node#27379 when floated as a patch against 64.2
1734da6
@jefgen minor, but if you squash, can you mention the original commit and issue? something like you could also make the first line of the commit a bit shorter. And i'll stop bikeshedding there. |
Thanks @srl295, those are good ideas. (I'll limit the first commit line to 70 chars max). |
This fixes a regression introduced by commit b12a927 for issue ICU-13778. The above commit improved the error checking in the DateTimePatternGenerator class, adding checks for errors/failures where there previously was none at all. This was done in order to catch catastrophic errors like out-of-memory (OOM), and properly report them to the caller, rather than ignoring/hiding these errors. However, in doing so it exposed a case where the code was depending on ignoring errors in order to fall-back to the Gregorian calendar when the default ICU locale is set to root. This restores the previous behavior, by allowing the error of U_MISSING_RESOURCE_ERROR to fall-though and continue without reporting back an error to the caller. Note: This regression was technically introduced in ICU 63, and also effects ICU 64 as well.
1734da6
to
3da02ca
Compare
Hooray! The files in the branch are the same across the force-push. 😃 ~ Your Friendly Jira-GitHub PR Checker Bot |
- Floating patch for ICU 63.x and 64.x - fixing crash in Intl when ICU data not found. - Regression test from refack included. Background: - ICU-13778 (landed in ICU 63.1) fixed a bug but added a regression. - a recent v8 land in Node v12 (which one?) exposes this bug to cause a crash when ICU data is not found. ICU Bug: https://unicode-org.atlassian.net/browse/ICU-20558 Backport of: unicode-org/icu#632 (Commit not landed yet in ICU) Fixes: nodejs#27379 Co-authored-by: Refael Ackermann <refack@gmail.com>
- Floating patch for ICU 63.x and 64.x - fixing crash in Intl when ICU data not found. - Regression test from refack included. Background: - ICU-13778 (landed in ICU 63.1) fixed a bug but added a regression. - a recent v8 land in Node v12 (which one?) exposes this bug to cause a crash when ICU data is not found. ICU Bug: https://unicode-org.atlassian.net/browse/ICU-20558 Backport of: unicode-org/icu#632 Fixes: nodejs#27379 Co-authored-by: Refael Ackermann <refack@gmail.com> PR-URL: nodejs#27415 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
- Floating patch for ICU 63.x and 64.x - fixing crash in Intl when ICU data not found. - Regression test from refack included. Background: - ICU-13778 (landed in ICU 63.1) fixed a bug but added a regression. - a recent v8 land in Node v12 (which one?) exposes this bug to cause a crash when ICU data is not found. ICU Bug: https://unicode-org.atlassian.net/browse/ICU-20558 Backport of: unicode-org/icu#632 Fixes: #27379 Co-authored-by: Refael Ackermann <refack@gmail.com> PR-URL: #27415 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
- Floating patch for ICU 63.x and 64.x - fixing crash in Intl when ICU data not found. - Regression test from refack included. Background: - ICU-13778 (landed in ICU 63.1) fixed a bug but added a regression. - a recent v8 land in Node v12 (which one?) exposes this bug to cause a crash when ICU data is not found. ICU Bug: https://unicode-org.atlassian.net/browse/ICU-20558 Backport of: unicode-org/icu#632 Fixes: #27379 Co-authored-by: Refael Ackermann <refack@gmail.com> PR-URL: #27415 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
- Floating patch for ICU 63.x and 64.x - fixing crash in Intl when ICU data not found. - Regression test from refack included. Background: - ICU-13778 (landed in ICU 63.1) fixed a bug but added a regression. - a recent v8 land in Node v12 (which one?) exposes this bug to cause a crash when ICU data is not found. ICU Bug: https://unicode-org.atlassian.net/browse/ICU-20558 Backport of: unicode-org/icu#632 Fixes: #27379 Co-authored-by: Refael Ackermann <refack@gmail.com> PR-URL: #27415 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
* fix: crash with icu when input locale is invalid Backports unicode-org/icu#632 * spec: add regression tests
(Thanks to @gvictor for tracking down the issue.)
This commit for ICU-13778 improved the error checking in the
DateTimePatternGenerator
class, adding checks for errors/failures where there previously was none at all. This was done in order to catch catastrophic errors like out-of-memory (OOM), and properly report them to the caller, rather than ignoring/hiding these errors.However, in doing so it exposed a case where the code was depending on ignoring errors in order to fallback to the Gregorian calendar when the default ICU locale is set to root.
This commit restores the previous behavior, by allowing the error of
U_MISSING_RESOURCE_ERROR
to fall-though and continue without reporting back an error.Note: This regression was introduced in ICU 63, and also effects ICU 64 as well.
Checklist