RFR: 8289220: Locale.forLanguageTag throws NPE due to soft ref used in locale cache being cleared [v3]
SUN Guoyun
duke at openjdk.org
Mon Jun 5 09:39:10 UTC 2023
On Thu, 1 Jun 2023 08:58:23 GMT, SUN Guoyun <duke at openjdk.org> wrote:
>> command: make test CONF=fastdebug JTREG="VM_OPTIONS=-Xcomp" TEST=gc/TestAllocHumongousFragment.java
>> error info:
>>
>> Caused by: java.lang.NullPointerException: Cannot invoke "sun.util.locale.BaseLocale.getVariant()" because "base" is null
>> at java.base/java.util.Locale.forLanguageTag(Locale.java:1802)
>> at java.base/sun.util.cldr.CLDRBaseLocaleDataMetaInfo.<clinit>(CLDRBaseLocaleDataMetaInfo.java:41)
>> ... 24 more
>>
>> Note that the test runs with -XX:ShenandoahGCHeuristics=aggressive -XX:+ShenandoahOOMDuringEvacALot and SoftReferences are involved (LocaleObjectCache uses SoftReferences, used by printf method called in getRandomInstance(Utils.java:511)).
>>
>> Maybe we have to deal with the case where the getBaseLocale() return value is null. the call stack is:
>>
>> at java.base/sun.util.locale.LocaleObjectCache.get(LocaleObjectCache.java:64)
>> at java.base/sun.util.locale.BaseLocale.getInstance(BaseLocale.java:169)
>> at java.base/sun.util.locale.InternalLocaleBuilder.getBaseLocale(InternalLocaleBuilder.java:524)
>> at java.base/java.util.Locale.forLanguageTag(Locale.java:1874)
>>
>> in LocaleObjectCache.java:64
>>
>> 62 if (key == null || newVal == null) {
>> 63 // subclass must return non-null key/value object
>> 64 return null; // run here
>> 65 }
>
> SUN Guoyun has refreshed the contents of this pull request, and previous commits have been removed. The incremental views will show differences compared to the previous content of the PR. The pull request contains one new commit since the last revision:
>
> 8289220: Locale.forLanguageTag throws NPE due to soft ref used in locale cache being cleared
Existing JMH Local test results be tested on LOONGARCH64 show no performance fallback.
<pre><code class="shell">
// parent
Benchmark Mode Cnt Score Error Units
LocaleDefaults.getDefault avgt 3 35.731 ± 0.805 ns/op
LocaleDefaults.getDefaultDisplay avgt 3 36.099 ± 1.037 ns/op
LocaleDefaults.getDefaultFormat avgt 3 36.123 ± 1.718 ns/op
// current
Benchmark Mode Cnt Score Error Units
LocaleDefaults.getDefault avgt 3 35.649 ± 0.264 ns/op
LocaleDefaults.getDefaultDisplay avgt 3 36.141 ± 1.283 ns/op
LocaleDefaults.getDefaultFormat avgt 3 36.092 ± 1.371 ns/op
</code></pre>
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14211#issuecomment-1576462477
More information about the core-libs-dev
mailing list