Uncaught exception "invalid language tag" in MozDateTimeFormat constructor

RESOLVED FIXED in Thunderbird 66.0

Status

defect
RESOLVED FIXED
5 months ago
4 months ago

People

(Reporter: ardovm, Assigned: jorgk)

Tracking

Thunderbird 66.0

Thunderbird Tracking Flags

(thunderbird_esr6065+ fixed, thunderbird66 fixed)

Details

Attachments

(3 attachments, 1 obsolete attachment)

Reporter

Description

5 months ago

User Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:64.0) Gecko/20100101 Firefox/64.0

Steps to reproduce:

Try to edit an address book entry

Actual results:

The debugger shows an uncaught exception in mozIntl.js:78
The constructor of MozDateTimeFormat calls getLocales(locales) and this raises a:
RangeError: invalid language tag: en-US-u-va-posix-u-ca-gregory-nu-latn

The exception is not caught, and therefore the initialization of the DatePicker is interrupted abruptly.
The effect is that, among others, the "yearField", "monthField" fields of the datePicker etc. are not created.

When trying to close the address book entry by clicking on "Ok", the window does not close, because it wants to access the aforementioned fields of the datePicker. An exception is raised and the window does not close.

Expected results:

IMHO exceptions should either be caught or either fail noisily.

Reporter

Comment 1

5 months ago

Here is some debug information.

Application Basics

Name: Thunderbird
Version: 60.4.0
Build ID: 20190115112610
User Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.8.1.24) Gecko/20100805 Lightning/0.9 Thunderbird/2.0.0.24 Mnenhy/0.7.6.666
OS: FreeBSD 11.2-STABLE

[...]

Extensions
Name
Version
Enabled
ID

    Lightning
    6.2.4
    true
    {e2fda1a4-762b-4020-b5ad-a41df1933103}

    Provider for Google Calendar
    4.4.2
    true
    {a62ef8ec-5fdc-40c2-873c-223b8a6925cc}

    Remove Duplicate Messages (Alternate)
    0.3.17b1
    true
    {a300a000-5e21-4ee0-a115-9ec8f4eaa92b}

[...]

Internationalization & Localization

  Application Settings
  Requested Locales: ["und","en-US"]
  Available Locales: ["en-US"]
  App Locales: ["en-US","und"]
  Regional Preferences: ["en-US-u-va-posix"]
  Default Locale: "und"

  Operating System
  System Locales: ["en-US-u-va-posix"]
  Regional Preferences: ["en-US-u-va-posix"]

Output of the `locale' command:

$ locale
LANG=
LC_CTYPE="C"
LC_COLLATE="C"
LC_TIME="C"
LC_NUMERIC="C"
LC_MONETARY="C"
LC_MESSAGES="C"
LC_ALL=

Please let me know if you need any more information.

Assignee

Updated

5 months ago
Component: Untriaged → Internationalization
Flags: needinfo?(gandalf)
Product: Thunderbird → Core
Version: 60 → 60 Branch

Bug 1505435 comment 20.

The code is here: https://searchfox.org/comm-central/source/common/bindings/datetimepicker.xml#493-494

It's a dirtyhack, and as such, it fails when poked long enough. :)

Since we're still waiting for bug 1433303, you can either set a dependency on it, or you'll need to write some simple parser/serializer for unicode extension keys to be able to extract them from locale, add yours, and rebuild the language tag with the new set.

The correct language tag should be en-US-u-va-posix-ca-gregory-nu-latn

A sliiightly safer dirty hack you could deploy is just test if -u- is already there and then just concatenate the ca-gregory-nu-latn instead.

Flags: needinfo?(gandalf)
Assignee

Comment 3

5 months ago

Ouch, our code, sorry, thanks for the pointers. We love problems in forked code (not) :-(

Component: Internationalization → XUL Replacements
Product: Core → MailNews Core
Version: 60 Branch → 60
Assignee

Comment 4

5 months ago
Posted patch 1521454-locale-hack.patch (obsolete) — Splinter Review

Would you do me the honour :-)

Assignee: nobody → jorgk
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #9039207 - Flags: review?(gandalf)
Comment on attachment 9039207 [details] [diff] [review]
1521454-locale-hack.patch

Review of attachment 9039207 [details] [diff] [review]:
-----------------------------------------------------------------

Yea, I would add a comment stating that it awaits for Intl.Locale and that the current solution is hacky because a locale code may have other extension keys (for example "en-US-u-hc-h12-t-foo-x-bar") and then it'll fail :)
Attachment #9039207 - Flags: review?(gandalf) → review+
Assignee

Comment 6

5 months ago

Thanks, Zibi, I'll add a comment in the landed version.

Assignee

Comment 7

5 months ago

Oops, missing closing parenthesis. Added now and also the comment.

Attachment #9039207 - Attachment is obsolete: true
Attachment #9039231 - Flags: review+

Comment 8

5 months ago

Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/0396f1f1c7a7
Avoid exception due to bad locale code when appending [-u]-ca-gregory-nu-latn. r=zibi

Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Assignee

Updated

5 months ago
Target Milestone: --- → Thunderbird 66.0
Reporter

Comment 9

4 months ago

First of all, thank you for taking care of this bug!

I was preparing a patch for my system, so I do not have to wait until version 66.
I found out that in the same file, the concatenation of "-u-something" is repeated in more than one place.
I am submitting a tentative patch that addresses them all, for your kind review. It should apply to 60.5.0

Reporter

Comment 10

4 months ago

Address the same problem in other points of the same file.
This patch should apply to sources version 60.5.0

Assignee

Comment 11

4 months ago
Comment on attachment 9041114 [details] [diff] [review]
patch-bug1521454

Damn, we missed some? I'll get the other places fixed. I'll look at it later today.
Attachment #9041114 - Flags: review?(jorgk)
Assignee

Comment 12

4 months ago
Comment on attachment 9041114 [details] [diff] [review]
patch-bug1521454

OK, this is the combined TB 60 ESR patch.
Attachment #9041114 - Flags: review?(jorgk) → approval-comm-esr60+

Comment 14

4 months ago
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/b3d0202faaa3
Follow-up: Avoid exception due to bad locale code when appending [-u]-ca-gregory-nu-latn (more call sites). r=jorgk
Assignee

Comment 15

4 months ago
Comment on attachment 9041266 [details] [diff] [review]
patch-bug1521454 - trunk patch, follow-up

Second part needs uplift.
Attachment #9041266 - Flags: approval-comm-beta+
Assignee

Updated

4 months ago
Duplicate of this bug: 1529648
You need to log in before you can comment on or make changes to this bug.