diff options
author | Joseph Myers <joseph@codesourcery.com> | 2013-09-03 15:32:54 +0000 |
---|---|---|
committer | Joseph Myers <joseph@codesourcery.com> | 2013-09-03 15:32:54 +0000 |
commit | ffa3cd7f1a472954e9be22a48140c6eef45c3ef5 (patch) | |
tree | 80e53151d62629bdfc55c3aebb7156d657e8e235 | |
parent | 8f02859f17d01ce0cf542d934a04a79f048b73fd (diff) | |
download | glibc-ffa3cd7f1a472954e9be22a48140c6eef45c3ef5.tar.gz glibc-ffa3cd7f1a472954e9be22a48140c6eef45c3ef5.tar.xz glibc-ffa3cd7f1a472954e9be22a48140c6eef45c3ef5.zip |
Fix lgammaf spurious underflow (bug 15427).
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | NEWS | 4 | ||||
-rw-r--r-- | math/libm-test.inc | 55 | ||||
-rw-r--r-- | sysdeps/i386/fpu/libm-test-ulps | 52 | ||||
-rw-r--r-- | sysdeps/ieee754/flt-32/e_lgammaf_r.c | 4 | ||||
-rw-r--r-- | sysdeps/x86_64/fpu/libm-test-ulps | 56 |
6 files changed, 176 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog index 015ef93877..f8e9f9a32a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2013-09-03 Joseph Myers <joseph@codesourcery.com> + + [BZ #15427] + * sysdeps/ieee754/flt-32/e_lgammaf_r.c (__ieee754_lgammaf_r): Use + 2**-30 instead of 2**-70 as threshold for returning -log(|x|). + * math/libm-test.inc (lgamma_test_data): Add more tests. + * sysdeps/i386/fpu/libm-test-ulps: Update. + * sysdeps/x86_64/fpu/libm-test-ulps: Likewise. + 2013-09-03 Ondřej Bílka <neleai@seznam.cz> * sysdeps/x86_64/multiarch/strcmp-sse2-unaligned.S: New file. diff --git a/NEWS b/NEWS index ee78ea44c9..d29f0d937e 100644 --- a/NEWS +++ b/NEWS @@ -9,8 +9,8 @@ Version 2.19 * The following bugs are resolved with this release: - 14155, 14699, 15522, 15531, 15532, 15736, 15749, 15797, 15867, 15886, - 15887, 15890, 15897, 15905, 15909, 15921. + 14155, 14699, 15427, 15522, 15531, 15532, 15736, 15749, 15797, 15867, + 15886, 15887, 15890, 15897, 15905, 15909, 15921. * CVE-2013-4237 The readdir_r function could write more than NAME_MAX bytes to the d_name member of struct dirent, or omit the terminating NUL diff --git a/math/libm-test.inc b/math/libm-test.inc index fb5e977670..fe85bb9f1d 100644 --- a/math/libm-test.inc +++ b/math/libm-test.inc @@ -9978,6 +9978,61 @@ static const struct test_f_f1_data lgamma_test_data[] = TEST_f_f1 (lgamma, -0.5, M_LOG_2_SQRT_PIl, -1), TEST_f_f1 (lgamma, 0.7L, 0.260867246531666514385732417016759578L, 1), TEST_f_f1 (lgamma, 1.2L, -0.853740900033158497197028392998854470e-1L, 1), + + TEST_f_f1 (lgamma, 0x1p-5L, 3.4484891277979584796832693452686366085801e+00L, 1), + TEST_f_f1 (lgamma, -0x1p-5L, 3.4845895751341394376217526729956836492792e+00L, -1), + TEST_f_f1 (lgamma, 0x1p-10L, 6.9309089024194618895406190646600805357273e+00L, 1), + TEST_f_f1 (lgamma, -0x1p-10L, 6.9320362775113082175565786721095494761582e+00L, -1), + TEST_f_f1 (lgamma, 0x1p-15L, 1.0397190093941001762077888432721419773538e+01L, 1), + TEST_f_f1 (lgamma, -0x1p-15L, 1.0397225324389321751118257981741350715545e+01L, -1), + TEST_f_f1 (lgamma, 0x1p-20L, 1.3862943060723899573457963336920089012399e+01L, 1), + TEST_f_f1 (lgamma, -0x1p-20L, 1.3862944161675408862049886226750366625112e+01L, -1), + TEST_f_f1 (lgamma, 0x1p-25L, 1.7328679496796266133304874243201700664713e+01L, 1), + TEST_f_f1 (lgamma, -0x1p-25L, 1.7328679531201000798551671833865469674673e+01L, -1), + TEST_f_f1 (lgamma, 0x1p-30L, 2.0794415416260785304085859198055798098863e+01L, 1), + TEST_f_f1 (lgamma, -0x1p-30L, 2.0794415417335933262374820960532606449975e+01L, -1), + TEST_f_f1 (lgamma, 0x1p-40L, 2.7725887222397287402100277256545578941303e+01L, 1), + TEST_f_f1 (lgamma, -0x1p-40L, 2.7725887222398337351278293820766115529596e+01L, -1), + TEST_f_f1 (lgamma, 0x1p-50L, 3.4657359027997264958191108994508978906983e+01L, 1), + TEST_f_f1 (lgamma, -0x1p-50L, 3.4657359027997265983532103151309975524744e+01L, -1), + TEST_f_f1 (lgamma, 0x1p-60L, 4.1588830833596718564533272505187468598519e+01L, 1), + TEST_f_f1 (lgamma, -0x1p-60L, 4.1588830833596718565534582069793719571779e+01L, -1), + TEST_f_f1 (lgamma, 0x1p-64L, 4.4361419555836499802671564849429355013920e+01L, 1), + TEST_f_f1 (lgamma, -0x1p-64L, 4.4361419555836499802734146697217245699749e+01L, -1), + TEST_f_f1 (lgamma, 0x1p-70L, 4.8520302639196171659205759581386516869302e+01L, 1), + TEST_f_f1 (lgamma, -0x1p-70L, 4.8520302639196171659206737422758202661268e+01L, -1), + TEST_f_f1 (lgamma, 0x1p-100L, 6.9314718055994530941723212145817201464678e+01L, 1), + TEST_f_f1 (lgamma, -0x1p-100L, 6.9314718055994530941723212145818112150422e+01L, -1), + TEST_f_f1 (lgamma, 0x1p-126L, 8.7336544750553108986571247303730247577506e+01L, 1), + TEST_f_f1 (lgamma, -0x1p-126L, 8.7336544750553108986571247303730247577520e+01L, -1), + TEST_f_f1 (lgamma, 0x1p-149L, 1.0327892990343185110316758609726830864325e+02L, 1), + TEST_f_f1 (lgamma, -0x1p-149L, 1.0327892990343185110316758609726830864325e+02L, -1), +#ifndef TEST_FLOAT + TEST_f_f1 (lgamma, 0x1p-200L, 1.3862943611198906188344642429163531361510e+02L, 1), + TEST_f_f1 (lgamma, -0x1p-200L, 1.3862943611198906188344642429163531361510e+02L, -1), + TEST_f_f1 (lgamma, 0x1p-500L, 3.4657359027997265470861606072908828403775e+02L, 1), + TEST_f_f1 (lgamma, -0x1p-500L, 3.4657359027997265470861606072908828403775e+02L, -1), + TEST_f_f1 (lgamma, 0x1p-1000L, 6.9314718055994530941723212145817656807550e+02L, 1), + TEST_f_f1 (lgamma, -0x1p-1000L, 6.9314718055994530941723212145817656807550e+02L, -1), + TEST_f_f1 (lgamma, 0x1p-1022L, 7.0839641853226410622441122813025645257316e+02L, 1), + TEST_f_f1 (lgamma, -0x1p-1022L, 7.0839641853226410622441122813025645257316e+02L, -1), + TEST_f_f1 (lgamma, 0x1p-1074L, 7.4444007192138126231410729844608163411309e+02L, 1), + TEST_f_f1 (lgamma, -0x1p-1074L, 7.4444007192138126231410729844608163411309e+02L, -1), +#endif +#if defined TEST_LDOUBLE && LDBL_MIN_EXP <= -16381 + TEST_f_f1 (lgamma, 0x1p-5000L, 3.4657359027997265470861606072908828403775e+03L, 1), + TEST_f_f1 (lgamma, -0x1p-5000L, 3.4657359027997265470861606072908828403775e+03L, -1), + TEST_f_f1 (lgamma, 0x1p-10000L, 6.9314718055994530941723212145817656807550e+03L, 1), + TEST_f_f1 (lgamma, -0x1p-10000L, 6.9314718055994530941723212145817656807550e+03L, -1), + TEST_f_f1 (lgamma, 0x1p-16382L, 1.1355137111933024058873096613727848538213e+04L, 1), + TEST_f_f1 (lgamma, -0x1p-16382L, 1.1355137111933024058873096613727848538213e+04L, -1), + TEST_f_f1 (lgamma, 0x1p-16445L, 1.1398805384308300613366382237379713662002e+04L, 1), + TEST_f_f1 (lgamma, -0x1p-16445L, 1.1398805384308300613366382237379713662002e+04L, -1), +# if LDBL_MANT_DIG >= 113 + TEST_f_f1 (lgamma, 0x1p-16494L, 1.1432769596155737933527826611331164313837e+04L, 1), + TEST_f_f1 (lgamma, -0x1p-16494L, 1.1432769596155737933527826611331164313837e+04L, -1), +# endif +#endif }; static void diff --git a/sysdeps/i386/fpu/libm-test-ulps b/sysdeps/i386/fpu/libm-test-ulps index 8244863ef6..4759aa9f7f 100644 --- a/sysdeps/i386/fpu/libm-test-ulps +++ b/sysdeps/i386/fpu/libm-test-ulps @@ -5470,9 +5470,35 @@ double: 1 idouble: 1 ildouble: 1 ldouble: 1 +Test "gamma (-0x1p-10)": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "gamma (-0x1p-15)": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "gamma (-0x1p-20)": +double: 1 +idouble: 1 +Test "gamma (-0x1p-30)": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "gamma (-0x1p-5)": +double: 1 +idouble: 1 Test "gamma (0.7)": float: 1 ifloat: 1 +Test "gamma (0x1p-40)": +ildouble: 1 +ldouble: 1 Test "gamma (1.2)": double: 1 float: 2 @@ -5723,9 +5749,35 @@ double: 1 idouble: 1 ildouble: 1 ldouble: 1 +Test "lgamma (-0x1p-10)": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +ildouble: 1 +ldouble: 1 +Test "lgamma (-0x1p-15)": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "lgamma (-0x1p-20)": +double: 1 +idouble: 1 +Test "lgamma (-0x1p-30)": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "lgamma (-0x1p-5)": +double: 1 +idouble: 1 Test "lgamma (0.7)": float: 1 ifloat: 1 +Test "lgamma (0x1p-40)": +ildouble: 1 +ldouble: 1 Test "lgamma (1.2)": double: 1 float: 2 diff --git a/sysdeps/ieee754/flt-32/e_lgammaf_r.c b/sysdeps/ieee754/flt-32/e_lgammaf_r.c index 2e92269085..0dba9af8d7 100644 --- a/sysdeps/ieee754/flt-32/e_lgammaf_r.c +++ b/sysdeps/ieee754/flt-32/e_lgammaf_r.c @@ -150,8 +150,8 @@ __ieee754_lgammaf_r(float x, int *signgamp) *signgamp = -1; return one/fabsf(x); } - if(__builtin_expect(ix<0x1c800000, 0)) { - /* |x|<2**-70, return -log(|x|) */ + if(__builtin_expect(ix<0x30800000, 0)) { + /* |x|<2**-30, return -log(|x|) */ if(hx<0) { *signgamp = -1; return -__ieee754_logf(-x); diff --git a/sysdeps/x86_64/fpu/libm-test-ulps b/sysdeps/x86_64/fpu/libm-test-ulps index 477eedc311..6fbfa64ae1 100644 --- a/sysdeps/x86_64/fpu/libm-test-ulps +++ b/sysdeps/x86_64/fpu/libm-test-ulps @@ -6222,11 +6222,39 @@ idouble: 1 Test "gamma (-0.5)": ildouble: 1 ldouble: 1 +Test "gamma (-0x1p-10)": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "gamma (-0x1p-15)": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "gamma (-0x1p-20)": +double: 1 +idouble: 1 +Test "gamma (-0x1p-30)": +ildouble: 1 +ldouble: 1 +Test "gamma (-0x1p-5)": +double: 1 +idouble: 1 Test "gamma (0.7)": double: 1 float: 1 idouble: 1 ifloat: 1 +Test "gamma (0x1p-10)": +float: 1 +ifloat: 1 +Test "gamma (0x1p-30)": +double: 1 +idouble: 1 +Test "gamma (0x1p-40)": +ildouble: 1 +ldouble: 1 Test "gamma (1.2)": double: 1 float: 2 @@ -6491,11 +6519,39 @@ ldouble: 2 Test "lgamma (-0.5)": ildouble: 1 ldouble: 1 +Test "lgamma (-0x1p-10)": +double: 1 +idouble: 1 +ildouble: 1 +ldouble: 1 +Test "lgamma (-0x1p-15)": +double: 1 +float: 1 +idouble: 1 +ifloat: 1 +Test "lgamma (-0x1p-20)": +double: 1 +idouble: 1 +Test "lgamma (-0x1p-30)": +ildouble: 1 +ldouble: 1 +Test "lgamma (-0x1p-5)": +double: 1 +idouble: 1 Test "lgamma (0.7)": double: 1 float: 1 idouble: 1 ifloat: 1 +Test "lgamma (0x1p-10)": +float: 1 +ifloat: 1 +Test "lgamma (0x1p-30)": +double: 1 +idouble: 1 +Test "lgamma (0x1p-40)": +ildouble: 1 +ldouble: 1 Test "lgamma (1.2)": double: 1 float: 2 |