The streams_tests/xor_file test fails on Windows #29014

issue hebasto openend this issue on December 6, 2023
  1. hebasto commented at 8:25 pm on December 6, 2023: member

    Is there an existing issue for this?

    • I have searched the existing issues

    Current behaviour

    0>.\bitcoin-26.0\bin\test_bitcoin.exe -t streams_tests/xor_file
    1Running 1 test case...
    2unknown location(0): fatal error: in "streams_tests/xor_file": std::ios_base::failure[abi:cxx11]: AutoFile::write: file handle is nullptr: iostream error
    3test/streams_tests.cpp(29): last checkpoint
    4
    5*** 1 failure is detected in the test module "Bitcoin Core Test Suite"
    

    Expected behaviour

    Tests pass with no errors.

    Steps to reproduce

    1. Download https://bitcoincore.org/bin/bitcoin-core-26.0/bitcoin-26.0-win64.zip
    2. Unpack the archive.
    3. Run test_bitcoin.exe in the terminal.

    Relevant log output

    No response

    How did you obtain Bitcoin Core

    Pre-built binaries

    What version of Bitcoin Core are you using?

    v26.0

    Operating system and version

    Windows 11 Pro 23H2

    Machine specifications

    No response

  2. hebasto added the label Windows on Dec 6, 2023
  3. hebasto added the label Tests on Dec 6, 2023
  4. fanquake commented at 8:27 pm on December 6, 2023: member

    Download https://bitcoincore.org/bin/bitcoin-core-25.1/bitcoin-25.1-win64.zip

    What version of Bitcoin Core are you using? v26.0

    Which version is it?

  5. hebasto commented at 8:30 pm on December 6, 2023: member
  6. maflcko added this to the milestone 26.1 on Dec 6, 2023
  7. fanquake commented at 3:04 pm on December 7, 2023: member
    We run these unit tests in the Windows CI: https://cirrus-ci.com/task/6292832290340864?logs=ci#L2787. So is this going to be some difference between the CI binaries & Guix Windows binaries?
  8. maflcko commented at 3:19 pm on December 7, 2023: member
    Maybe your Windows doesn’t understand the “wbx” flags? (C++17, https://en.cppreference.com/w/cpp/io/c/fopen)
  9. hebasto commented at 3:23 pm on December 7, 2023: member

    So is this going to be some difference between the CI binaries & Guix Windows binaries?

    Cross-compiled binaries fail, not only Guix. It seems there is a difference between CI environment and a regular Windows installation?

  10. fanquake commented at 3:25 pm on December 7, 2023: member

    Cross-compiled binaries fail,

    Ok, but they don’t fail in our CI. So I guess this is some difference between Wine and actual Windows? Needs more info if we are going to be able to debug anything.

  11. maflcko commented at 3:26 pm on December 7, 2023: member

    Maybe your Windows doesn’t understand the “wbx” flags? (C++17, https://en.cppreference.com/w/cpp/io/c/fopen)

    So to clarify, can you re-try by removing the x? (I don’t have Windows, so I can’t try)

  12. fanquake commented at 3:28 pm on December 7, 2023: member
    According to https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/fopen-wfopen?view=msvc-170 x should be supported, but maybe it is broken.
  13. hebasto commented at 3:41 pm on December 7, 2023: member

    Maybe your Windows doesn’t understand the “wbx” flags? (C++17, en.cppreference.com/w/cpp/io/c/fopen)

    So to clarify, can you re-try by removing the x? (I don’t have Windows, so I can’t try)

    With the diff as follows:

     0--- a/src/test/streams_tests.cpp
     1+++ b/src/test/streams_tests.cpp
     2@@ -29,7 +29,7 @@ BOOST_AUTO_TEST_CASE(xor_file)
     3         BOOST_CHECK_EXCEPTION(xor_file.ignore(1), std::ios_base::failure, HasReason{"AutoFile::ignore: file handle is nullpt"});
     4     }
     5     {
     6-        AutoFile xor_file{raw_file("wbx"), xor_pat};
     7+        AutoFile xor_file{raw_file("wb"), xor_pat};
     8         xor_file << test1 << test2;
     9     }
    10     {
    

    the test passes.

  14. maflcko added the label Upstream on Dec 7, 2023
  15. pablomartin4btc commented at 7:31 pm on December 15, 2023: member

    I’ve also tested the fix above provided by @hebasto and it works as expected, thanks!

    Tested it running all tests successfully on Windows 11 Pro after a cross-build on Ubuntu 22.04 with the fix above.

    0.\test_bitcoin.exe --show_progress=true
    1Running 588 test cases...
    2
    30%   10   20   30   40   50   60   70   80   90   100%
    4|----|----|----|----|----|----|----|----|----|----|
    5***************************************************
    6
    7*** No errors detected
    
  16. maflcko commented at 12:26 pm on January 25, 2024: member
    Is this fixed in a later version of gcc?
  17. hebasto commented at 4:32 pm on January 30, 2024: member

    Is this fixed in a later version of gcc?

    After cross-compiling on Ubuntu 23.10 the issue still remains.

    0$ x86_64-w64-mingw32-g++-posix --version
    1x86_64-w64-mingw32-g++-posix (GCC) 12-posix
    2Copyright (C) 2022 Free Software Foundation, Inc.
    3This is free software; see the source for copying conditions.  There is NO
    4warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
  18. hebasto commented at 5:01 pm on January 30, 2024: member

    The same error when using Ubuntu 24.04:

    0$ x86_64-w64-mingw32-g++-posix --version
    1x86_64-w64-mingw32-g++-posix (GCC) 13-posix
    2Copyright (C) 2023 Free Software Foundation, Inc.
    3This is free software; see the source for copying conditions.  There is NO
    4warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    
  19. maflcko commented at 5:10 pm on January 30, 2024: member
    Ok, as a next step it could make sense to create a standalone reproducer, so that the bug can be reported upstream.
  20. fanquake closed this on Feb 26, 2024

  21. fanquake referenced this in commit 4d7d7fd123 on Feb 26, 2024

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-01 10:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me