Skip to content
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

Exception on Linux when using the time zone "America/Buenos_Aires" #103864

Closed
stalek71 opened this issue Jun 23, 2024 · 9 comments
Closed

Exception on Linux when using the time zone "America/Buenos_Aires" #103864

stalek71 opened this issue Jun 23, 2024 · 9 comments

Comments

@stalek71
Copy link

Description

After deploying a small hobbyist application that displays the times for all time zones available in .NET, the application throws an exception when trying to create a TimeZoneInfo for America/Buenos_Aires (as well as for some other time zones).
On Windows, this time zone is correctly created with this ID, but on Linux, this time zone is named America/Argentina/Buenos_Aires

Reproduction Steps

Please just run this code below on Windows and Linux (console app).
I used the latest version of .NET 8 available on Ubuntu (8.0.105) with this one setting in project def file:

<InvariantGlobalization>false</InvariantGlobalization>

static async Task Main(string[] args)
{
       // "America/Argentina/Buenos_Aires", "Argentina Standard Time", "America/Buenos_Aires"
       var timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Buenos_Aires");
       var localTime = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, timeZoneInfo);

       Console.WriteLine($"Local time is {localTime} (for zone {timeZoneInfo.Id})");
}

Expected behavior

America/Buenos_Aires is resolved proper way on linux (I used Ubuntu)

Actual behavior

Throws an exception

Regression?

No response

Known Workarounds

No response

Configuration

Linux x64, latest .Net 8 SDK, tzdata installed

Other information

No response

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jun 23, 2024
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-datetime
See info in area-owners.md if you want to be subscribed.

@danmoseley
Copy link
Member

Adding some info for whoever triages. Using 8.0.6 on Ubuntu 22.04.3 the code above succeeds for me.

In case it's relevant

dan@danmose50:~/proj/loc$ dotnet build > nul
dan@danmose50:~/proj/loc$ strace -o out dotnet exec bin/Debug/net8.0/loc.dll
Hello, World!
Local time is 06/23/2024 15:06:16 (for zone America/Buenos_Aires)
dan@danmose50:~/proj/loc$ cat out | grep icu | grep -v 'No such'
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libicuuc.so.70", O_RDONLY|O_CLOEXEC) = 26
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libicudata.so.70", O_RDONLY|O_CLOEXEC) = 26
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libicui18n.so.70", O_RDONLY|O_CLOEXEC) = 26
newfstatat(AT_FDCWD, "/usr/share/zoneinfo-icu/44/le/timezoneTypes.res", {st_mode=S_IFREG|0644, st_size=20256, ...}, 0) = 0
openat(AT_FDCWD, "/usr/share/zoneinfo-icu/44/le/timezoneTypes.res", O_RDONLY) = 31
newfstatat(AT_FDCWD, "/usr/share/zoneinfo-icu/44/le/zoneinfo64.res", {st_mode=S_IFREG|0644, st_size=151344, ...}, 0) = 0
openat(AT_FDCWD, "/usr/share/zoneinfo-icu/44/le/zoneinfo64.res", O_RDONLY) = 31
newfstatat(AT_FDCWD, "/usr/share/zoneinfo-icu/44/le/windowsZones.res", {st_mode=S_IFREG|0644, st_size=22624, ...}, 0) = 0
openat(AT_FDCWD, "/usr/share/zoneinfo-icu/44/le/windowsZones.res", O_RDONLY) = 31

what is the similar output for you?

@danmoseley
Copy link
Member

also please share exception/callstack.

@danmoseley
Copy link
Member

And please share Ubuntu version/bitness

@stalek71
Copy link
Author

stalek71 commented Jun 23, 2024

Below is short system (and distro) info.
Trace file is in the attachment.

alek@hp-srv:~/work/tz-issue$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 24.04 LTS
Release:        24.04
Codename:       noble
alek@hp-srv:~/work/tz-issue$ hostnamectl
 Static hostname: hp-srv
       Icon name: computer-desktop
         Chassis: desktop 🖥️
      Machine ID: 24a2c7775ac34fbc8d1f81d1be3b81f2
         Boot ID: ea37e01a107442a4b7b24bdfed3aa655
Operating System: Ubuntu 24.04 LTS
          Kernel: Linux 6.8.0-35-generic
    Architecture: x86-64
 Hardware Vendor: HP
  Hardware Model: HP EliteDesk 800 G2 DM 35W
Firmware Version: N21 Ver. 02.47
   Firmware Date: Mon 2020-04-27
    Firmware Age: 4y 1month 3w 6d
alek@hp-srv:~/work/tz-issue$ inxi
CPU: quad core Intel Core i5-6500T (-MCP-) speed/min/max: 800/800/3100 MHz
Kernel: 6.8.0-35-generic x86_64 Up: 5d 12h 12m Mem: 1.5/30.77 GiB (4.9%)
Storage: 8.21 TiB (1.1% used) Procs: 230 Shell: Bash inxi: 3.3.34

Stack info:

alek@hp-srv:~/work/tz-issue$ dotnet tz-issue.dll
Hello, World!
Unhandled exception. System.TimeZoneNotFoundException: The time zone ID 'America/Buenos_Aires' was not found on the local computer.
 ---> System.IO.FileNotFoundException: Could not find file '/usr/share/zoneinfo/America/Buenos_Aires'.
File name: '/usr/share/zoneinfo/America/Buenos_Aires'
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
   at System.TimeZoneInfo.ReadAllBytesFromSeekableNonZeroSizeFile(String path, Int32 maxFileSize)
   at System.TimeZoneInfo.TryGetTimeZoneFromLocalMachineCore(String id, TimeZoneInfo& value, Exception& e)
   --- End of inner exception stack trace ---
   at System.TimeZoneInfo.FindSystemTimeZoneById(String id)
   at tz_issue.Program.Main(String[] args) in D:\Projects\tz-issue\Program.cs:line 9
Aborted (core dumped)
alek@hp-srv:~/work/tz-issue$ strace -o some_trace dotnet exec tz-issue.dll
Hello, World!
Unhandled exception. System.TimeZoneNotFoundException: The time zone ID 'America/Buenos_Aires' was not found on the local computer.
 ---> System.IO.FileNotFoundException: Could not find file '/usr/share/zoneinfo/America/Buenos_Aires'.
File name: '/usr/share/zoneinfo/America/Buenos_Aires'
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, Int64 preallocationSize)
   at System.TimeZoneInfo.ReadAllBytesFromSeekableNonZeroSizeFile(String path, Int32 maxFileSize)
   at System.TimeZoneInfo.TryGetTimeZoneFromLocalMachineCore(String id, TimeZoneInfo& value, Exception& e)
   --- End of inner exception stack trace ---
   at System.TimeZoneInfo.FindSystemTimeZoneById(String id)
   at tz_issue.Program.Main(String[] args) in D:\Projects\tz-issue\Program.cs:line 9
Aborted (core dumped)

Trace file:
some_trace.zip

@stalek71
Copy link
Author

Some info about installed tz package yet...

alek@hp-srv:~/work/tz-issue$ dpkg -l | grep tzdata
ii  tzdata                                        2024a-3ubuntu1.1                         all          time zone and daylight-saving time data
alek@hp-srv:~/work/tz-issue$

Cache:

alek@hp-srv:~/work/tz-issue$ apt-cache show tzdata
Package: tzdata
Architecture: all
Version: 2024a-3ubuntu1.1
Multi-Arch: foreign
Priority: important
Section: libs
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 1381
Provides: tzdata-trixie
Depends: debconf (>= 0.5) | debconf-2.0
Breaks: tzdata-legacy (= 2023c-8ubuntu1)
Replaces: tzdata-legacy (= 2023c-8ubuntu1)
Filename: pool/main/t/tzdata/tzdata_2024a-3ubuntu1.1_all.deb
Size: 273458
MD5sum: cea29cad5692fa3b963059ebd4f1060d
SHA1: 10981e631577457df27af52d6c6adb34b3a36ed7
SHA256: 8b39de44bcfccb7069405e7cee3598678d65f42eb015e4eca254f684975ddaa1
SHA512: 66a406f4c9d8d280c8328a6ed88b70ef8a8e563f94ab0376009efa8a91c40e861e88d5dc95aa26b8dffbe5baf098c9cc6491959811ab4d1a1021ca88edbe0d0d
Homepage: https://www.iana.org/time-zones
Description-en: time zone and daylight-saving time data
 This package contains data required for the implementation of
 standard local time for many representative locations around the
 globe. It is updated periodically to reflect changes made by
 political bodies to time zone boundaries, UTC offsets, and
 daylight-saving rules.
Description-md5: a77a3cc9a67658dd7cfdc6547391b8f8
Task: cloud-minimal, minimal, server-minimal

Package: tzdata
Architecture: all
Version: 2024a-2ubuntu1
Multi-Arch: foreign
Priority: important
Section: libs
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Original-Maintainer: GNU Libc Maintainers <debian-glibc@lists.debian.org>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 1381
Provides: tzdata-trixie
Depends: debconf (>= 0.5) | debconf-2.0
Breaks: tzdata-legacy (= 2023c-8ubuntu1)
Replaces: tzdata-legacy (= 2023c-8ubuntu1)
Filename: pool/main/t/tzdata/tzdata_2024a-2ubuntu1_all.deb
Size: 273318
MD5sum: cdea0e0fbad525fedd4a7288ea90e760
SHA1: 7112a68d98a745959626d8fe2926fb8e76975b21
SHA256: f5bca0c788a4fc465c435f7e8a54b2594e9cbf1a22abb263a59e393f1cb666e1
SHA512: 5fe9adc5f67931713fa7b5bc3b6d64cf00b0c83f5e2a21b8a2a7fa783fc8dee692b3c3dd24444bab461a88ac5f5c956872ba076b75e314a6c97e7f213ce8107a
Homepage: https://www.iana.org/time-zones
Description-en: time zone and daylight-saving time data
 This package contains data required for the implementation of
 standard local time for many representative locations around the
 globe. It is updated periodically to reflect changes made by
 political bodies to time zone boundaries, UTC offsets, and
 daylight-saving rules.
Description-md5: a77a3cc9a67658dd7cfdc6547391b8f8
Task: cloud-minimal, minimal, server-minimal

alek@hp-srv:~/work/tz-issue$

@Clockwork-Muse
Copy link
Contributor

Going by the list of entries on wikipedia, the "correct" entry is America/Argentina/Buenos_Aires, and America/Buenos_Aires is a backwards-compatible link.

In Ubuntu 22.04 (@danmoseley 's version), this is implemented as a filesystem link:

-rw-r--r--  1 root root   246 Feb 21 04:50 Bogota
-rw-r--r--  1 root root  2410 Feb 21 04:50 Boise
lrwxrwxrwx  1 root root    22 Feb 21 04:50 Buenos_Aires -> Argentina/Buenos_Aires
-rw-r--r--  1 root root  2254 Feb 21 04:50 Cambridge_Bay
-rw-r--r--  1 root root  1444 Feb 21 04:50 Campo_Grande

In Ubuntu24.04 (@stalek71 's version), the relevant origin file is entirely missing in the operating system (verified by pulling a docker image):

-rw-r--r--  1 root root  246 May  3 11:27 Bogota
-rw-r--r--  1 root root 2410 May  3 11:27 Boise
-rw-r--r--  1 root root 2254 May  3 11:27 Cambridge_Bay
-rw-r--r--  1 root root 1444 May  3 11:27 Campo_Grande

Which would probably make this a package maintainer problem.

I'm not sure why the file was removed - there are other backwards-compat links that are present in the files.

@tarekgh
Copy link
Member

tarekgh commented Jun 24, 2024

Thanks @Clockwork-Muse. I am closing this issue, it is tzdata packaging issue. It is weird though as I am still seeing https://github.com/eggert/tz/blob/3c39cde86bf36dfab1ceb88a4ab9e11a3ec9c1df/backward#L143 still maintaining the backward mapping. Looks to me the package builder built it excluding America/Buenos_Aires

@tarekgh tarekgh closed this as completed Jun 24, 2024
@dotnet-policy-service dotnet-policy-service bot removed the untriaged New issue has not been triaged by the area owner label Jun 24, 2024
@bdrung
Copy link

bdrung commented Jul 3, 2024

As mentioned in the "tzdata package split" section on the Ubuntu 24.04 release notes, the tzdata package was split into tzdata, tzdata-icu, and tzdata-legacy. Please install tzdata-legacy if you want the backward compatibility links.

@github-actions github-actions bot locked and limited conversation to collaborators Aug 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants