Bug 240219

Summary: Flakey test case: sys.sys.qmath_test.qdivq_s64q
Product: Base System Reporter: Li-Wen Hsu <lwhsu>
Component: testsAssignee: Lawrence Stewart <lstewart>
Status: Open ---    
Severity: Affects Only Me CC: emaste, lstewart, markj, rlibby
Priority: ---    
Version: CURRENT   
Hardware: Any   
OS: Any   

Description Li-Wen Hsu freebsd_committer freebsd_triage 2019-08-30 20:02:26 UTC
sys.sys.qmath_test.qdivq_s64q is unstable:

https://ci.freebsd.org/job/FreeBSD-head-amd64-test/12369/testReport/junit/sys.sys/qmath_test/qdivq_s64q/
https://ci.freebsd.org/job/FreeBSD-head-amd64-test/12387/testReport/junit/sys.sys/qmath_test/qdivq_s64q/
https://ci.freebsd.org/job/FreeBSD-head-amd64-test/12392/testReport/junit/sys.sys/qmath_test/qdivq_s64q/

*** Check failed: /usr/src/tests/sys/sys/qmath_test.c:308: 	QDIVQ(-10002376169421.736328 / -15034320172614.007812): | 98.402039 -   0.665303| =  97.736736 (max err 64.000000)

Also on i386:
https://ci.freebsd.org/job/FreeBSD-head-i386-test/6533/testReport/sys.sys/qmath_test/qdivq_s64q/
https://ci.freebsd.org/job/FreeBSD-head-i386-test/6519/testReport/sys.sys/qmath_test/qdivq_s64q/
https://ci.freebsd.org/job/FreeBSD-head-i386-test/6515/testReport/sys.sys/qmath_test/qdivq_s64q/

*** Check failed: /usr/src/tests/sys/sys/qmath_test.c:308: 	QDIVQ(-62708492.456048 / -164807648.004718): | 96.661085 -   0.380495| =  96.280590 (max err 64.000000)
Comment 1 Li-Wen Hsu freebsd_committer freebsd_triage 2019-08-30 20:03:45 UTC
trasz: can you help check this?
Comment 2 commit-hook freebsd_committer freebsd_triage 2019-09-03 10:49:33 UTC
A commit references this bug:

Author: lwhsu
Date: Tue Sep  3 10:49:13 UTC 2019
New revision: 351739
URL: https://svnweb.freebsd.org/changeset/base/351739

Log:
  Temporarily skip sys.sys.qmath_test.qdivq_s64q in CI because it is unstable

  PR:		240219
  Discussed with:	trasz
  Sponsored by:	The FreeBSD Foundation

Changes:
  head/tests/sys/sys/qmath_test.c
Comment 3 Ryan Libby freebsd_committer freebsd_triage 2020-12-11 23:14:50 UTC
I've seen this running kyua for dev testing too.  It repros very
regularly with:

% kyua debug -k /usr/tests/sys/sys/Kyuafile qmath_test:qdivq_s64q

*** Check failed: /usr/src/freebsd/tests/sys/sys/qmath_test.c:312: 	QDIVQ(-3223.957586 /  -4.348088): | -0.000000 - 741.465557| = 741.465557 (max err 64.000000)
*** Check failed: /usr/src/freebsd/tests/sys/sys/qmath_test.c:312: 	QDIVQ( -0.666057 /  -0.006838): | -0.000000 -  97.403647| =  97.403647 (max err 64.000000)
*** Check failed: /usr/src/freebsd/tests/sys/sys/qmath_test.c:312: 	QDIVQ(-12136258505124932.000000 / -37248647815101.328125): |  6.546875 - 325.817425| = 319.270550 (max err 64.000000)
*** Check failed: /usr/src/freebsd/tests/sys/sys/qmath_test.c:312: 	QDIVQ(-119840516.277450 / -1321356.097985): |  2.831561 -  90.695095| =  87.863533 (max err 64.000000)

It seems in all repros so far both the numerator and denominator are
negative.
Comment 4 Ryan Libby freebsd_committer freebsd_triage 2024-05-27 19:15:06 UTC
Okay, actually reading Q_QDIVQ, I believe it is just completely
incorrect.  Like 1/1 != 1.

It is so wrong that I wonder if it should either just always set the
result as zero, or an error of EOPNOTSUP, or be removed.  I do not see
any uses of Q_QDIVQ in the tree except for this test.

If someone does want to fix it, the cases for types of no more than 32
bits are trivially addressed.  64 bits is a little harder to make fast
without assuming compiler support for large ints, but if we are willing
to sacrifice a little accuracy (and why not, considering the current
code is catastrophically wrong), it's possible to get a reasonably close
result.
Comment 5 Mark Johnston freebsd_committer freebsd_triage 2024-06-26 21:03:41 UTC
Lawrence, would you be able to take a look at this?  Like Ryan, I occasionally hit this failure in my test runs and it'd be nice to either fix this macro or remove it.
Comment 6 Lawrence Stewart freebsd_committer freebsd_triage 2024-07-01 23:56:51 UTC
ACK. This issue was supposed to be cleaned up as part of upstreaming, but it looks like it needs further TLC.
Comment 7 Mark Linimon freebsd_committer freebsd_triage 2024-09-25 10:42:03 UTC
^Triage: committer's bit was taken in for safekeeping.