public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug testsuite/101866] New: libstdc++-v3/testsuite/experimental/random/randint.cc fails
@ 2021-08-11 19:41 seurer at gcc dot gnu.org
  2021-08-11 19:46 ` [Bug testsuite/101866] " redi at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: seurer at gcc dot gnu.org @ 2021-08-11 19:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101866

            Bug ID: 101866
           Summary: libstdc++-v3/testsuite/experimental/random/randint.cc
                    fails
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
          Assignee: unassigned at gcc dot gnu.org
          Reporter: seurer at gcc dot gnu.org
  Target Milestone: ---

libstdc++-v3/testsuite/experimental/random/randint.cc fails on rare occasions. 
I have only seen it happen twice now once after running it 1.9 million times to
try to spot it:

/home/seurer/gcc/git/gcc-9-test/libstdc++-v3/testsuite/experimental/random/randint.cc:61:
void test01(): Assertion '!(n3[0] == n1[0] && n3[1] == n1[1] && n3[2] ==
n1[2])' failed.
/home/seurer/bin/runmany.gcc: line 212: 39222 Aborted                 (core
dumped) ./randint.exe

While I spotted this with gcc 9 the test has not changed in current trunk anmd
I assume in gcc 10 and gcc 11 as well.

OK,

  std::experimental::reseed(99u);
  const long n1[] = {
    std::experimental::randint(0, 100),
    std::experimental::randint(0, 100),
    std::experimental::randint(0, 100),
    std::experimental::randint(0, 100),
    std::experimental::randint(0, 100)
  };
. . .
  std::experimental::reseed();
  const long n3[] = {
    std::experimental::randint(0, 100),
    std::experimental::randint(0, 100),
    std::experimental::randint(0, 100)
  };
  VERIFY( !(n3[0] == n1[0] && n3[1] == n1[1] && n3[2] == n1[2]) );

I don't think the above code from the test is correct.  There is a small chance
(1 in 100 for each) that the values in n3 will be the same as the values in n1.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug testsuite/101866] libstdc++-v3/testsuite/experimental/random/randint.cc fails
  2021-08-11 19:41 [Bug testsuite/101866] New: libstdc++-v3/testsuite/experimental/random/randint.cc fails seurer at gcc dot gnu.org
@ 2021-08-11 19:46 ` redi at gcc dot gnu.org
  2021-08-11 19:51 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-11 19:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101866

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-08-11

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug testsuite/101866] libstdc++-v3/testsuite/experimental/random/randint.cc fails
  2021-08-11 19:41 [Bug testsuite/101866] New: libstdc++-v3/testsuite/experimental/random/randint.cc fails seurer at gcc dot gnu.org
  2021-08-11 19:46 ` [Bug testsuite/101866] " redi at gcc dot gnu.org
@ 2021-08-11 19:51 ` redi at gcc dot gnu.org
  2021-08-11 19:51 ` redi at gcc dot gnu.org
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-11 19:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101866

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
If the 32 bits read from /dev/random by reseed() happen to equal 99u then
there's a 100% chance that the values will be the same.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug testsuite/101866] libstdc++-v3/testsuite/experimental/random/randint.cc fails
  2021-08-11 19:41 [Bug testsuite/101866] New: libstdc++-v3/testsuite/experimental/random/randint.cc fails seurer at gcc dot gnu.org
  2021-08-11 19:46 ` [Bug testsuite/101866] " redi at gcc dot gnu.org
  2021-08-11 19:51 ` redi at gcc dot gnu.org
@ 2021-08-11 19:51 ` redi at gcc dot gnu.org
  2021-08-11 22:46 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-11 19:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101866

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |redi at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug testsuite/101866] libstdc++-v3/testsuite/experimental/random/randint.cc fails
  2021-08-11 19:41 [Bug testsuite/101866] New: libstdc++-v3/testsuite/experimental/random/randint.cc fails seurer at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2021-08-11 19:51 ` redi at gcc dot gnu.org
@ 2021-08-11 22:46 ` cvs-commit at gcc dot gnu.org
  2021-08-11 22:46 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11 22:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101866

--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:93f1dbc7cdcc4b31ea4061efb4c2acf2d4f81eb8

commit r12-2866-g93f1dbc7cdcc4b31ea4061efb4c2acf2d4f81eb8
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Aug 11 22:11:19 2021 +0100

    libstdc++: Fix test that fails randomly [PR101866]

    This test assumes that the same sequence of three values cannot occur,
    which is incorect. It's unlikely, but not impossible.

    Perform the check in a loop, so that in the unlikely event of an
    identical sequence, we retry. If the library code is buggy it will keep
    producing the same sequence and the test will time out. If the code is
    working correctly then we will usually break out of the loop after one
    iteration, or very rarely after two or three.

    libstdc++-v3/ChangeLog:

            PR libstdc++/101866
            * testsuite/experimental/random/randint.cc: Loop and retry if
            reseed() produces the same sequence.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug testsuite/101866] libstdc++-v3/testsuite/experimental/random/randint.cc fails
  2021-08-11 19:41 [Bug testsuite/101866] New: libstdc++-v3/testsuite/experimental/random/randint.cc fails seurer at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2021-08-11 22:46 ` cvs-commit at gcc dot gnu.org
@ 2021-08-11 22:46 ` redi at gcc dot gnu.org
  2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-11 22:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101866

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed on trunk, but I'll backport it too.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug testsuite/101866] libstdc++-v3/testsuite/experimental/random/randint.cc fails
  2021-08-11 19:41 [Bug testsuite/101866] New: libstdc++-v3/testsuite/experimental/random/randint.cc fails seurer at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2021-08-11 22:46 ` redi at gcc dot gnu.org
@ 2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
  2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11 22:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101866

--- Comment #4 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-11 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:6e3647c98e474d0f204061859996356e6af5ae8d

commit r11-8854-g6e3647c98e474d0f204061859996356e6af5ae8d
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Aug 11 22:11:19 2021 +0100

    libstdc++: Fix test that fails randomly [PR101866]

    This test assumes that the same sequence of three values cannot occur,
    which is incorect. It's unlikely, but not impossible.

    Perform the check in a loop, so that in the unlikely event of an
    identical sequence, we retry. If the library code is buggy it will keep
    producing the same sequence and the test will time out. If the code is
    working correctly then we will usually break out of the loop after one
    iteration, or very rarely after two or three.

    libstdc++-v3/ChangeLog:

            PR libstdc++/101866
            * testsuite/experimental/random/randint.cc: Loop and retry if
            reseed() produces the same sequence.

    (cherry picked from commit 93f1dbc7cdcc4b31ea4061efb4c2acf2d4f81eb8)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug testsuite/101866] libstdc++-v3/testsuite/experimental/random/randint.cc fails
  2021-08-11 19:41 [Bug testsuite/101866] New: libstdc++-v3/testsuite/experimental/random/randint.cc fails seurer at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
@ 2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
  2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
  2021-08-11 22:54 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11 22:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101866

--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:f1318b1d317b529cdd474a7660a82d47b228a054

commit r10-10032-gf1318b1d317b529cdd474a7660a82d47b228a054
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Aug 11 22:11:19 2021 +0100

    libstdc++: Fix test that fails randomly [PR101866]

    This test assumes that the same sequence of three values cannot occur,
    which is incorect. It's unlikely, but not impossible.

    Perform the check in a loop, so that in the unlikely event of an
    identical sequence, we retry. If the library code is buggy it will keep
    producing the same sequence and the test will time out. If the code is
    working correctly then we will usually break out of the loop after one
    iteration, or very rarely after two or three.

    libstdc++-v3/ChangeLog:

            PR libstdc++/101866
            * testsuite/experimental/random/randint.cc: Loop and retry if
            reseed() produces the same sequence.

    (cherry picked from commit 93f1dbc7cdcc4b31ea4061efb4c2acf2d4f81eb8)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug testsuite/101866] libstdc++-v3/testsuite/experimental/random/randint.cc fails
  2021-08-11 19:41 [Bug testsuite/101866] New: libstdc++-v3/testsuite/experimental/random/randint.cc fails seurer at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
@ 2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
  2021-08-11 22:54 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-08-11 22:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101866

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-9 branch has been updated by Jonathan Wakely
<redi@gcc.gnu.org>:

https://gcc.gnu.org/g:326a020be21aeec77eab9a7247c0591c56745b37

commit r9-9670-g326a020be21aeec77eab9a7247c0591c56745b37
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Aug 11 22:11:19 2021 +0100

    libstdc++: Fix test that fails randomly [PR101866]

    This test assumes that the same sequence of three values cannot occur,
    which is incorect. It's unlikely, but not impossible.

    Perform the check in a loop, so that in the unlikely event of an
    identical sequence, we retry. If the library code is buggy it will keep
    producing the same sequence and the test will time out. If the code is
    working correctly then we will usually break out of the loop after one
    iteration, or very rarely after two or three.

    libstdc++-v3/ChangeLog:

            PR libstdc++/101866
            * testsuite/experimental/random/randint.cc: Loop and retry if
            reseed() produces the same sequence.

    (cherry picked from commit 93f1dbc7cdcc4b31ea4061efb4c2acf2d4f81eb8)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug testsuite/101866] libstdc++-v3/testsuite/experimental/random/randint.cc fails
  2021-08-11 19:41 [Bug testsuite/101866] New: libstdc++-v3/testsuite/experimental/random/randint.cc fails seurer at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
@ 2021-08-11 22:54 ` redi at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2021-08-11 22:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101866

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
   Target Milestone|---                         |9.5
             Status|ASSIGNED                    |RESOLVED

--- Comment #7 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for 9.5, 10.4 and 11.3, thanks for noticing the failures.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-08-11 22:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-11 19:41 [Bug testsuite/101866] New: libstdc++-v3/testsuite/experimental/random/randint.cc fails seurer at gcc dot gnu.org
2021-08-11 19:46 ` [Bug testsuite/101866] " redi at gcc dot gnu.org
2021-08-11 19:51 ` redi at gcc dot gnu.org
2021-08-11 19:51 ` redi at gcc dot gnu.org
2021-08-11 22:46 ` cvs-commit at gcc dot gnu.org
2021-08-11 22:46 ` redi at gcc dot gnu.org
2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
2021-08-11 22:52 ` cvs-commit at gcc dot gnu.org
2021-08-11 22:54 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).