You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Platform:
Linux 8a6b069d5b19 4.10.0-22-generic Simple project messaging. #24~16.04.1-Ubuntu SMP Tue May 23 17:03:51 UTC 2017 x86_64 GNU/Linux
Subsystem:
Ubuntu
We're using Jest on Travis for testing and discovered that after Node upgraded from v7.9.0 to v8.4.0 some tests failed. That's okay I thought, but. Finally, I found this odd behavior:
Maybe I missed some breaking changes, so I'll appreciate any help with that.
Otherwise, I think it's a regression and we should reflect on the proper solution.
parsedLength: if not NULL, successfully parsed length for the input language tag is set
Returns: the length of the locale ID.
So the returned value should actually be used for the icu_length parameter and checked, instead of parsedLength.
For the test case in the OP, bcp47_locale contains "und" as normalized by other layers, so icu_length would always be 3. This piece of code would then read icu_result which is uninitializd. This might explain a bit of non-deterministic behaviors between different ICU versions and different machines (e.g. why @bnoordhuis's patch fixes the tests for him).
If that were fixed, we should also use the default ICU locale instead of returning NULL, to truly fix the tests.
All of this is included in the following patch, which fixes this bug and also factors out the common BCP 47 conversion code for me:
@srl295 I think the problem lies in the fact that V8 isn't getting the default ICU locale, not that ICU changed its behaviors. The default locale did not change between 58 and 59, nor did the from/toLanguageTag functions.
Late reproduction that reframes this: it wasn't Russian locale data. On the small-icu builds these Nodes shipped, the default fallback locale changed:
7.10.1: 'ru-RU' resolves to en-US-u-va-posix -> $9.00
8.0.0: 'ru-RU' resolves to und -> US$ 9.00
With real full-ICU data installed, output is identical on both (9,00 $). resolvedOptions().locale is the one-line diagnostic for this whole class - I've since automated it in https://github.com/jay123anta/intl-drift for anyone hitting similar drift on upgrades.
Activity
TimothyGu commentedon Sep 6, 2017
Just wondering, do you have full-icu installed?
sclinede commentedon Sep 6, 2017
Nope! Only the small-icu that we have already packed.
Also, this bug is not reproducible on Mac by default.
On homebrew
nodeis installed with system-icu option (proof).sclinede commentedon Sep 7, 2017
Further investigation showed that the fallback logic for unknown locale changed:
sclinede commentedon Sep 7, 2017
And we don't have any test for that. We just verify that in case of unknown locale we return defaults here.
TimothyGu commentedon Sep 7, 2017
Interestingly,
%GetDefaultICULocale()returnsen-USso that test would fail on Node.js v8.x...@nodejs/intl Please weigh in.
TimothyGu commentedon Sep 7, 2017
So it looks like the test case is hitting this piece of code in V8...
node/deps/v8/src/objects/intl-objects.cc
Lines 456 to 459 in 56a0577
the comment makes it look like there is a legitimate bug somewhere. Digging deeper...
bnoordhuis commentedon Sep 7, 2017
v8/v8@2b5a36d from July might or might not help with this. It's not in our tree yet.
TimothyGu commentedon Sep 7, 2017
@bnoordhuis Unfortunately that commit does not fix this. I think I got to the bottom of this, however. The key lies in the following lines:
node/deps/v8/src/objects/intl-objects.cc
Lines 707 to 720 in 56a0577
The docs for
uloc_forLanguageTagsays:So the returned value should actually be used for the
icu_lengthparameter and checked, instead ofparsedLength.For the test case in the OP,
bcp47_localecontains"und"as normalized by other layers, soicu_lengthwould always be 3. This piece of code would then readicu_resultwhich is uninitializd. This might explain a bit of non-deterministic behaviors between different ICU versions and different machines (e.g. why @bnoordhuis's patch fixes the tests for him).If that were fixed, we should also use the default ICU locale instead of returning NULL, to truly fix the tests.
All of this is included in the following patch, which fixes this bug and also factors out the common BCP 47 conversion code for me:
Does this patch look okay to be submitted to V8?
/cc @nodejs/v8 @addaleax
srl295 commentedon Sep 8, 2017
@sclinede I don't think this is a bug. The display for
USDchanged toUS$because there are a lot of currencies which use the dollarsign in the world.TimothyGu commentedon Sep 8, 2017
@srl295 I think the problem lies in the fact that V8 isn't getting the default ICU locale, not that ICU changed its behaviors. The default locale did not change between 58 and 59, nor did the from/toLanguageTag functions.
25 remaining items
deps: cherry-pick 6989b3f6d7 from V8 upstream
deps: cherry-pick 6989b3f6d7 from V8 upstream
deps: cherry-pick 6989b3f6d7 from V8 upstream
deps: cherry-pick 6989b3f6d7 from V8 upstream
jay123anta commentedon Aug 16, 2026
Late reproduction that reframes this: it wasn't Russian locale data. On the small-icu builds these Nodes shipped, the default fallback locale changed:
With real full-ICU data installed, output is identical on both (
9,00 $).resolvedOptions().localeis the one-line diagnostic for this whole class - I've since automated it in https://github.com/jay123anta/intl-drift for anyone hitting similar drift on upgrades.