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

optionaltest failing on FreeBSD #2871

Open
rhelmot opened this issue Sep 4, 2023 · 3 comments
Open

optionaltest failing on FreeBSD #2871

rhelmot opened this issue Sep 4, 2023 · 3 comments

Comments

@rhelmot
Copy link

rhelmot commented Sep 4, 2023

On FreeBSD, I get the following output:

$ jq 'last(range(365 * 67)|("1970-03-01T01:02:03Z"|strptime("%Y-%m-%dT%H:%M:%SZ")|mktime) + (86400 * .)|strftime("%Y-%m-%dT%H:%M:%SZ")|strptime("%Y-%m-%dT%H:%M:%SZ"))' <<<null
[
  2037,
  1,
  11,
  1,
  2,
  3,
  2,
  41
]

On linux (ubuntu 22.04), I get the following (correct, probably) output:

$ jq 'last(range(365 * 67)|("1970-03-01T01:02:03Z"|strptime("%Y-%m-%dT%H:%M:%SZ")|mktime) + (86400 * .)|strftime("%Y-%m-%dT%H:%M:%SZ")|strptime("%Y-%m-%dT%H:%M:%SZ"))' <<<null

[
  2037,
  1,
  11,
  1,
  2,
  3,
  3,
  41
]

Both of these are from the jq installed from the operating system package manager. I verified that the FreeeBSD one works the same when built from source.

I have a suspicion that the difference is a bug in FreeBSD's libc, but I don't know enough about the functions being used to verify this. I'll gladly report it upstream if we can isolate the bug to a C snippet, but until then this is a jq test suite problem :)

@nicowilliams
Copy link
Contributor

nicowilliams commented Sep 5, 2023

Hi, do the patches in #2863 help?

EDIT: Hmm, no, #2863 probably won't help as it is right now. It seems we probably need to add the same workaround we have for OS X for FreeBSD (see set_tm_wday() in src/builtin.c).

@nicowilliams
Copy link
Contributor

nicowilliams commented Sep 5, 2023

Can you find out if on FreeBSD the tm_wday field is 0..6 or 1..7?

This looks like a bug on FreeBSD. February 11, 2037, looks like it would be a Wednesday according to every online calendar and every smartphone calendar app I checked, as well as according to cal(1) on Linux.

Well, I'll see if maybe it's a bug in set_tm_wday() in src/builtin.c, but it shouldn't be called on FreeBSD if its strptime() sets it.

@rhelmot
Copy link
Author

rhelmot commented Sep 5, 2023

re: struck comment, I can confirm that 2 = Tuesday on FreeBSD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants