Bug 1392247
Summary: | ocaml-zarith fails tests on ppc64le | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Richard W.M. Jones <rjones> |
Component: | ocaml-zarith | Assignee: | Jerry James <loganjerry> |
Status: | CLOSED EOL | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | 26 | CC: | loganjerry |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | ppc64le | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | If docs needed, set a value | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2018-05-29 11:46:39 UTC | Type: | Bug |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
Richard W.M. Jones
2016-11-06 20:29:27 UTC
Are you building in a side tag? I just tried building in mock on one of the Brno openpower hub ppc64le boxes, and even after wiping out the mock cache and building with --enablerepo=local I'm still getting ocaml 4.02.3-3.fc25. Perhaps the mirrors haven't caught up yet. The build succeeds and all tests pass with that version of ocaml, by the way. Yes you need to install the f26-ocaml packages. Try adding the following repo to your machine: $ cat /etc/yum.repos.d/tmp-f26-ocaml.repo [f26-ocaml] name=f26-ocaml baseurl=https://kojipkgs.fedoraproject.org/repos/f26-ocaml/latest/$basearch/ enabled=1 gpgcheck=0 I still don't really understand what's going on here, but the problem appears to happen in the Val_long(x) cast here: https://github.com/bobot/zarith/blob/master/caml_z.c#L524 I added lots of debugging around this part of the code. On ppc64 (thought to be correct): x = -1 Z_MIN_INT_FL = -4611686018427383808 Z_MAX_INT_FL = 4611686018427383808 x as Long = -1 (uintnat)(x) = 18446744073709551615 (uintnat)(x) << 1 = 18446744073709551614 (intnat) ((uintnat)(x) << 1) = -2 ((intnat) ((uintnat)(x) << 1)) + 1 = -1 On ppc64le (incorrect): x = -1 Z_MIN_INT_FL = -4611686018427383808 Z_MAX_INT_FL = 4611686018427383808 x as Long = 1 (uintnat)(x) = 0 (uintnat)(x) << 1 = 0 (intnat) ((uintnat)(x) << 1) = 0 ((intnat) ((uintnat)(x) << 1)) + 1 = 1 Why on earth does (uintnat)(-1) return 0? That makes no sense to me. (I'm assuming that uintnat is unsigned long) OK so as far as I can tell this is undefined behaviour in C: https://stackoverflow.com/questions/10541200/is-the-behaviour-of-casting-a-negative-double-to-unsigned-int-defined-in-the-c-s https://gcc.gnu.org/ml/gcc-help/2010-04/msg00140.html and therefore the Zarith code is wrong. This patch fixes things for me. I'm going to drop it into our ocaml-zarith package to get things moving along. diff --git a/caml_z.c b/caml_z.c index b690a2a..42d3850 100644 --- a/caml_z.c +++ b/caml_z.c @@ -521,7 +521,7 @@ CAMLprim value ml_z_of_float(value v) Z_MARK_OP; x = Double_val(v); #if Z_USE_NATINT - if (x >= Z_MIN_INT_FL && x <= Z_MAX_INT_FL) return Val_long(x); + if (x >= Z_MIN_INT_FL && x <= Z_MAX_INT_FL) return Val_long((intnat)x); #endif Z_MARK_SLOW; #ifdef ARCH_ALIGN_INT64 Thank you for figuring this out, Richard. I will send your patch upstream, with attribution. Hi Jerry, there is a thread on caml-list where this was discussed: https://sympa.inria.fr/sympa/arc/caml-list/2016-11/msg00013.html So Xavier is aware of the problem/fix. But it would be good to make sure a patch gets added upstream and not forgotten about. And here it is: http://forge.ocamlcore.org/tracker/index.php?func=detail&aid=1704&group_id=243&atid=1096 This bug appears to have been reported against 'rawhide' during the Fedora 26 development cycle. Changing version to '26'. This message is a reminder that Fedora 26 is nearing its end of life. Approximately 4 (four) weeks from now Fedora will stop maintaining and issuing updates for Fedora 26. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '26'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 26 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete. Fedora 26 changed to end-of-life (EOL) status on 2018-05-29. Fedora 26 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed. |