Bug 1763127
Summary: | R-bit64: bit64.so must be linked with -lm due to use of math functions | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | Elliott Sales de Andrade <quantum.analyst> |
Component: | R-bit64 | Assignee: | Elliott Sales de Andrade <quantum.analyst> |
Status: | CLOSED ERRATA | QA Contact: | Fedora Extras Quality Assurance <extras-qa> |
Severity: | unspecified | Docs Contact: | |
Priority: | unspecified | ||
Version: | rawhide | CC: | aoliva, arjun.is, codonell, dj, fweimer, hannsj_uhl, law, mfabian, pfrankli, quantum.analyst, rth, siddhesh |
Target Milestone: | --- | ||
Target Release: | --- | ||
Hardware: | Unspecified | ||
OS: | Unspecified | ||
Whiteboard: | |||
Fixed In Version: | R-bit64-0.9.7-8.fc31 R-bit64-0.9.7-6.fc29 R-bit64-0.9.7-6.fc30 | Doc Type: | If docs needed, set a value |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2019-11-15 03:01:15 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: | |||
Bug Depends On: | |||
Bug Blocks: | 467765, 1697085, 1734895 |
Description
Elliott Sales de Andrade
2019-10-18 10:10:18 UTC
Elliot, What we need is exactly the arguments you pass to llroundl so we can create a simple C reproducer for this. Can you provide the value passed to llroundl, and the expected value versus result? Even just one value is enough. The input is just powers of two (2**0, 2**1, ..., up to 2305843009213693952), multiplied by two. The result should of course just be powers of two (2**1, 2**2, ...). Roughly speaking, if you expand the macro, and use constants, it should be: long long e1 = 2; // or any other power of two. double e1 = 2.0; long double longret = e1 * (long double) e2; if (isnan(longret) || longret>MAX_INTEGER64){ // this case should not be true... naflag = TRUE; ret = NA_INTEGER64; } else { ret = llroundl(longret); } and `ret` should be 4; it _is_ 4 if you replace llroundl by a (long long) cast. I tried to turn comment 2 into something that actually compiles and came up with this: #include <stdio.h> #include <math.h> #include <limits.h> int main (void) { long long e1 = 2; // or any other power of two. double e2 = 2.0; long double longret = e1 * (long double) e2; long long ret; if (isnan(longret) || longret > LONG_MAX){ // this case should not be true... ret = 0; } else { ret = llroundl (longret); } printf ("%lld\n", ret); } Is this what you had in mind? I built it with -O0 (to rule out compiler optimizations) and ran it against glibc-2.30.9000-16.fc32.s390x. It prints 4 for me. This was on a z13. Anyway, I can reproduce this issue, but the bug is not in llround. It is clearly called with invalid arguments: (gdb) c Continuing. i64[-63]*2 Breakpoint 1, __llround (x=2) at ../sysdeps/ieee754/dbl-64/s_llround.c:31 31 { (gdb) finish Run till exit from #0 __llround (x=2) at ../sysdeps/ieee754/dbl-64/s_llround.c:31 0x000003fff9a0cec6 in times_integer64_double (e1_=<optimized out>, e2_=<optimized out>, ret_=0x2aa00d6fca0) at integer64.c:334 334 integer64.c: No such file or directory. Value returned is $1 = 2 (gdb) c Continuing. Breakpoint 1, __llround (x=2.125) at ../sysdeps/ieee754/dbl-64/s_llround.c:31 31 { (gdb) finish Run till exit from #0 __llround (x=2.125) at ../sysdeps/ieee754/dbl-64/s_llround.c:31 0x000003fff9a0cec6 in times_integer64_double (e1_=<optimized out>, e2_=<optimized out>, ret_=0x2aa00d6fca0) at integer64.c:334 334 integer64.c: No such file or directory. Value returned is $2 = 2 (gdb) The SEXPs appear to be correct, so that's not it. Do you know by chance how to compile R extension modules without the build harness, and how to load them into an installed R interpreter? I want to expand the macros and single-step through the code. Eh. I see now that __llround is being called here, not llroundl, and the argument is treated incorrectly as a double value, while it's actually long double according to the assembler code. Curiously, the PLT stub is for llroundl: 0x000003fff9a05ff0 in llroundl@plt () from /usr/lib64/R/library/bit64/libs/bit64.so But that jumps to __llround in glibc. Hah, found it! # eu-readelf -d /usr/lib64/R/library/bit64/libs/bit64.so Dynamic segment contains 31 entries: Addr: 0x0000000000020ae8 Offset: 0x01fae8 Link to section: [ 4] '.dynstr' Type Value NEEDED Shared library: [libR.so] NEEDED Shared library: [libc.so.6] INIT 0x00000000000058b0 bit64.so is underlinked, so the reference to llroundl is unversioned: # eu-readelf --symbols=.dynsym /usr/lib64/R/library/bit64/libs/bit64.so | grep llroundl 33: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UNDEF llroundl This is bound to the base symbol version, llroundl. At that version, long double and double were still the same type, so this ends up effectively calling llround, and llroundl. The fix is to link bit64.so with -lm. Ah, thank you very much; I don't think I would have figured this out quickly. FEDORA-2019-f71081d6ca has been submitted as an update to Fedora 31. https://bodhi.fedoraproject.org/updates/FEDORA-2019-f71081d6ca FEDORA-2019-a83a51a62b has been submitted as an update to Fedora 30. https://bodhi.fedoraproject.org/updates/FEDORA-2019-a83a51a62b FEDORA-2019-5efd44a88b has been submitted as an update to Fedora 29. https://bodhi.fedoraproject.org/updates/FEDORA-2019-5efd44a88b R-bit64-0.9.7-8.fc31 has been pushed to the Fedora 31 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-f71081d6ca R-bit64-0.9.7-6.fc29 has been pushed to the Fedora 29 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-5efd44a88b R-bit64-0.9.7-6.fc30 has been pushed to the Fedora 30 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2019-a83a51a62b R-bit64-0.9.7-8.fc31 has been pushed to the Fedora 31 stable repository. If problems still persist, please make note of it in this bug report. R-bit64-0.9.7-6.fc29 has been pushed to the Fedora 29 stable repository. If problems still persist, please make note of it in this bug report. R-bit64-0.9.7-6.fc30 has been pushed to the Fedora 30 stable repository. If problems still persist, please make note of it in this bug report. |