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

fix portability problems, found in NetBSD-7.1/amd64 #1458

Closed
wants to merge 4 commits into from

Conversation

n-soda
Copy link

@n-soda n-soda commented Aug 3, 2017

There are 4 portability problems in jq,

For example, it dumps core as follows on NetBSD-7.1/amd64, as described in https://gnats.netbsd.org/52460 :

$ echo 334 | jq 'strftime("%Y-%m-%dT%H:%M:%SZ")'
Memory fault (core dumped)

This is caused by missing function prototype of gmtime_r() due to inconsistent use of *_SOURCE macros, and that's fixed in df9a096 in this pull request.

There are 3 other problems, and all of them are fixed in this pull request.

NOTE: this problem was originally found by Takehiko NOZAKI, and basic fixes are made by him and Kimihiro Nonaka. But if there is any problem in these fixes, it's my fault since I made final modification.

n-soda added 4 commits August 3, 2017 20:55
 * "$<" is not portable here.
   It's portable only in an inference rule and the .DEFAULT rule.

 * "$^" is a GNU extension

See the following definition for detail:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/make.html#tag_20_76_13_08
pow10() and exp10() don't exist on NetBSD-7.1,
but the m4 macros in config/ fail to detect the fact,
because gcc silently optimize pow10(0.5) and exp10(0.5) to constants.
so, use rand() to disable the optimization.
defining _GNU_SOURCE, _BSD_SOURCE etc. in C sources is problematic,
because the result of the configure command may be inconsistent with it.
to be consistent, such macros have to be defined in the early stage of
the configure command, and the AC_USE_SYSTEM_EXTENSIONS macro does the job.
passing a signed char is not really portable,
and NetBSD is sensitive about this problem.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 79.901% when pulling cdc55ec on n-soda:netbsd-fix into 7b81a83 on stedolan:master.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Aug 19, 2018
Apply patch written by <soda> and shared with upstream as part of
<jqlang/jq#1458> in order to fix crashes of jq when
using date builtin functions.

Also add a SUBST class intended to avoid invoking git as part of pre-configure
phase when invoking autoreconf.

While here take the MAINTAINERship and reformat a bit the Makefile
(NFCI).

Thanks a lot to <soda>, Takehiko NOZAKI and <nonaka> for investigating
the issue, writing the patches, sharing them with upstream and as
part of PR pkg/52460!

Bump PKGREVISION
@emanuele6
Copy link
Member

This PR is now outdated; it addresses problems that were already fixed when jq 1.6 was released in 2018.

Closing.

@emanuele6 emanuele6 closed this Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants