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

glibc looking for zoneinfo files in the wrong place; failing silently #65415

Open
cdyson37 opened this issue Jul 26, 2019 · 3 comments
Open

glibc looking for zoneinfo files in the wrong place; failing silently #65415

cdyson37 opened this issue Jul 26, 2019 · 3 comments
Labels
0.kind: bug Something is broken 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: non-nixos Running packages on non-NixOS Linux

Comments

@cdyson37
Copy link
Contributor

When calling e.g. localtime, glibc looks zoneinfo files in its own derivation, and not in tzdata. Missing timezones are silently ignored (I believe this bit is not nixpkgs-specific), so in the example below, the output is off by one hour.

To Reproduce

$ cat localtime.c 
#include <time.h>
#include <stdio.h>

int main ()
{
  /* Fri 26 Jul 12:53:20 UTC 2019 */
  time_t t = 1564145600;
  struct tm *result = localtime (&t);
  if (result == NULL)
  {
    puts ("Error");
    return 1;
  }
  puts (asctime (result));

  return 0;
}

$ nix-shell -p gcc --run "gcc localtime.c -o localtime" && TZ=Europe/London ./localtime
Fri Jul 26 12:53:20 2019

strace shows its looking in the glibc derivation for zoneinfo, but actually the zoneinfo files are stored elsewhere.

$ TZ=Europe/London strace ./localtime |& grep London
openat(AT_FDCWD, "/nix/store/681354n3k44r8z90m35hm8945vsp95h1-glibc-2.27/share/zoneinfo/Europe/London", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)

Expected behavior
On Centos 7 (correct output)

$ gcc localtime.c -o localtime && TZ=Europe/London ./localtime
Fri Jul 26 13:53:20 2019

Metadata

  • system: "x86_64-linux"
  • host os: Linux 3.10.0-957.12.1.el7.x86_64, CentOS Linux, 7 (Core)
  • multi-user?: no
  • sandbox: no
  • version: nix-env (Nix) 2.2.2
  • channels(dyson): "nixpkgs-19.03.172807.b2ec3b6db2b, nixos-19.03-19.03"
  • nixpkgs: /home/dyson/.nix-defexpr/channels/nixpkgs

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: glibc
# a list of nixos modules affected by the problem
module:
@cdyson37 cdyson37 added the 0.kind: bug Something is broken label Jul 26, 2019
@matthewbauer matthewbauer added this to the 19.09 milestone Jul 26, 2019
@matthewbauer
Copy link
Member

I get this on my NixOS machine:

openat(AT_FDCWD, "/etc/zoneinfo/Europe/London", O_RDONLY|O_CLOEXEC) = 3

But this is probably because TZDIR=/etc/zoneinfo. Does /etc/zoneinfo or /usr/share/zoneinfo exist on CentOS?

@cdyson37
Copy link
Contributor Author

/usr/share/zoneinfo does exist on CentOS and setting TZDIR to point to that does fix the problem - thanks!

But I prefer not to rely on impure environment variables to get the correct behaviour, so for the time being I will probably overlay glibc to get consistency.

@matthewbauer matthewbauer modified the milestones: 19.09, 20.03 Aug 15, 2019
@disassembler disassembler modified the milestones: 20.03, 20.09 Feb 10, 2020
@matthewbauer matthewbauer removed this from the 20.09 milestone Mar 30, 2020
@veprbl veprbl added the 6.topic: non-nixos Running packages on non-NixOS Linux label Jun 5, 2020
@stale
Copy link

stale bot commented Dec 2, 2020

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: non-nixos Running packages on non-NixOS Linux
Projects
None yet
Development

No branches or pull requests

4 participants