Bug 1663489 - Math functions missing errno settings on underflow
Summary: Math functions missing errno settings on underflow
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: glibc
Version: 8.1
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: rc
: 8.0
Assignee: glibc team
QA Contact: qe-baseos-tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-01-04 14:05 UTC by Joe Wright
Modified: 2023-07-18 14:30 UTC (History)
6 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-01-14 20:20:38 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
reproducer (10.00 KB, application/x-tar)
2019-01-04 14:05 UTC, Joe Wright
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1575709 0 medium CLOSED Math functions missing errno settings on underflow 2023-07-18 14:30:35 UTC

Internal Links: 1575709

Description Joe Wright 2019-01-04 14:05:20 UTC
Created attachment 1518405 [details]
reproducer

Description of problem:
- errno is not being set for bessel functions such as j0, j1, jn, and also exp2.  In the case of exp2 it IS setting the fe exception – so we can catch that one.  But the j0-n are a problem since the man page documentation on RHEL 6 specifically states they do NOT set the IEEE fe exception for fetestexcept(), but they should be setting errno.

This seems to match this bug report:
https://sourceware.org/bugzilla/show_bug.cgi?id=18611

Version-Release number of selected component (if applicable):
- beta

How reproducible:
- see attached jtest.tar

Steps to Reproduce:
1.
2.
3.

Actual results:
] cat /etc/redhat-release
Red Hat Enterprise Linux release 8.0 Beta (Ootpa)
] g++ --version
g++ (GCC) 8.2.1 20180905 (Red Hat 8.2.1-3)
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

] g++ jtest.C -o jtest.rhel8
] jtest.rhel8
Testing J0:
  Before function call, errno = 0, exception query returns 0
  Calling j0( 1e+256 )
  After function call, errno = 0, exception query returns 0
  Returned function value = 2.04732e-131
Testing J1:
  Before function call, errno = 0, exception query returns 0
  Calling j1( 1e+256 )
  After function call, errno = 0, exception query returns 0
  Returned function value = 7.97882e-129
Testing JN:
  Before function call, errno = 0, exception query returns 0
  Calling jn( 1, 1e+24 )
  After function call, errno = 0, exception query returns 0
  Returned function value = -7.83133e-13
Testing EXP2:
  Before function call, errno = 0, exception query returns 0
  Calling exp2( -1222 )
  After function call, errno = 34, exception query returns 16
  Returned function value = 0

Following is running the RHEL6-compiled binary on RHEL8 beta, which gets the same wrong answers as running the RHEL8b-compiled binary on RHEL8b:

] jtest.rhel6
Testing J0:
  Before function call, errno = 0, exception query returns 0
  Calling j0( 1e+256 )
  After function call, errno = 0, exception query returns 0
  Returned function value = 2.04732e-131
Testing J1:
  Before function call, errno = 0, exception query returns 0
  Calling j1( 1e+256 )
  After function call, errno = 0, exception query returns 0
  Returned function value = 7.97882e-129
Testing JN:
  Before function call, errno = 0, exception query returns 0
  Calling jn( 1, 1e+24 )
  After function call, errno = 0, exception query returns 0
  Returned function value = -7.83133e-13
Testing EXP2:
  Before function call, errno = 0, exception query returns 0
  Calling exp2( -1222 )
  After function call, errno = 34, exception query returns 16
  Returned function value = 0

Expected results:

RHEL 6 glibc provides results which are expected by the user.
[alanm@vmw102 C02014182]$ ./jtest
Testing J0:
  Before function call, errno = 0, exception query returns 0
  Calling j0( 1e+256 )
  After function call, errno = 34, exception query returns 0
  Returned function value = 0
Testing J1:
  Before function call, errno = 0, exception query returns 0
  Calling j1( 1e+256 )
  After function call, errno = 34, exception query returns 0
  Returned function value = 0
Testing JN:
  Before function call, errno = 0, exception query returns 0
  Calling jn( 1, 1e+24 )
  After function call, errno = 34, exception query returns 0
  Returned function value = 0
Testing EXP2:
  Before function call, errno = 0, exception query returns 0
  Calling exp2( -1222 )
  After function call, errno = 34, exception query returns 0
  Returned function value = 0
[alanm@vmw102 C02014182]$ rpm -qf /lib64/libm.so.6
glibc-2.12-1.209.el6_9.2.x86_64

Additional info:

Comment 1 Florian Weimer 2019-01-04 14:24:13 UTC
The glibc manual says this (under Math Error Reporting):

“
When underflow occurs, the underflow exception is raised, and zero
(appropriately signed) or a subnormal value, as appropriate for the
mathematical result of the function and the rounding mode, is returned.
ERRNO may be set to ‘ERANGE’, but this is not guaranteed; it is intended
that the GNU C Library should set it when the underflow is to an
appropriately signed zero, but not necessarily for other underflows.
”

<https://www.gnu.org/software/libc/manual/html_node/Math-Error-Reporting.html>

So I don't think this is a bug in glibc.

Comment 2 Matt Newsome 2019-01-14 20:20:38 UTC
Closing this bug out as it doesn't, on the basis of the information provided, appear to be a bug. If you disagree, please reopen the bug with further supporting information and we'll take a look. Thanks.


Note You need to log in before you can comment on or make changes to this bug.