Bug 1575709

Summary: Math functions missing errno settings on underflow
Product: Red Hat Enterprise Linux 8 Reporter: Alan Matsuoka <alanm>
Component: glibcAssignee: glibc team <glibc-bugzilla>
Status: CLOSED NEXTRELEASE QA Contact: qe-baseos-tools-bugs
Severity: medium Docs Contact:
Priority: medium    
Version: 8.0CC: ashankar, codonell, cww, dj, fweimer, mnewsome, pfrankli
Target Milestone: pre-dev-freeze   
Target Release: 8.0   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-11-20 21:51:19 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: 1594286    
Attachments:
Description Flags
reproducer none

Description Alan Matsuoka 2018-05-07 17:09:25 UTC
Description of problem:
What problem/issue/behavior are you having trouble with?  What do you expect to see?

We are finding that our application is affected by a bug in the RHEL 7 math library, where 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):

All RHEL 7 flavors running glibc older that 2.23
also all glibc newer than 2.12

How reproducible:

always

Steps to Reproduce:
1. run reproducer in jtest.tar
2.
3.

Actual results:


RHEL 7:

ash-4.2$ ./jtest
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 = 0, exception query returns 16
  Returned function value = 0
bash-4.2$ ldd -r ./jtest
	linux-vdso.so.1 =>  (0x00007ffffb53c000)
	libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f20a521a000)
	libm.so.6 => /lib64/libm.so.6 (0x00007f20a4f18000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f20a4d01000)
	libc.so.6 => /lib64/libc.so.6 (0x00007f20a493e000)
	/lib64/ld-linux-x86-64.so.2 (0x000055dcbf791000)
bash-4.2$ rpm -qf /lib64/libm.so.6
glibc-2.17-196.el7_4.2.x86_64
[alanm@localhost-live C02014182]$ ./jtest
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
[alanm@localhost-live C02014182]$ rpm -q glibc
glibc-2.26-24.fc27.x86_64

It has the patch in https://sourceware.org/bugzilla/show_bug.cgi?id=18611 
and it does NOT do the correct thing.

I'm suspecting that the wrapper functions to the __ieee754_jXXX functions need to
be more like the RHEL 6 versions


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 2 Alan Matsuoka 2018-05-07 17:10:09 UTC
Created attachment 1432750 [details]
reproducer

Comment 4 Carlos O'Donell 2018-05-22 16:08:05 UTC
Thanks for filling this Alan, we'll review this as part of normal bug review process.

Comment 5 Carlos O'Donell 2018-11-20 21:51:19 UTC
The Platform Tools glibc team has decided that this will not be fixed in the Red Hat Enterprise Linux 7 product. The sequences of changes is rather extensive and not limited to just the few functions in question. The codebase is based on upstream glibc 2.17 which for libm has drifted considerably, and so the risk and cost of making changes like this is quite high. Upstream has improved errno settings in this area though, and those improvements are available in Red Hat Enterprise Linux 8, which has a public beta for test. Please ask the customer to look into reviewing if Red Hat Enterprise Linux 8 meets their needs. I'm marking this issue CLOSED/NEXTRELEASE.