Cirrus CI / Win64 doesn't print assert errors from test_bitcoin.exe #24261

issue ryanofsky opened this issue on February 4, 2022
  1. ryanofsky commented at 1:56 PM on February 4, 2022: contributor

    Cirrus CI / Win64 build does not seem to print errors from test_bitcoin.exe if an assert statement fails. I saw this recently in https://cirrus-ci.com/task/6752891435220992?logs=ci#L3597 from #24251, and reproduced it locally running FILE_ENV=./ci/test/00_setup_env_win64.sh ./ci/test_run_all.sh.

    If I run test_bitcoin.exe manually with docker exec I can see:

    test/util_tests.cpp(54): Entering test case "util_datadir"
    Assertion failed: fs::equivalent(result, path), file util/system.cpp, line 256
    

    But the default docker / cirrus output just shows the test_bitcoin.exe process exiting without any information about a failing assert.

    I don't know if this is a known limitation, but it would be helpful if windows CI builds were able to print why they are failing in cases like this.

  2. ryanofsky added the label Bug on Feb 4, 2022
  3. maflcko commented at 2:38 PM on February 4, 2022: member

    This should not happen, maybe stderr isn't redirected properly or so?

    Does this also happen in Ubuntu?

    For reference, the command is:

    src/Makefile.test.include:      $(AM_V_at)$(TEST_BINARY) --catch_system_errors=no -l test_suite -t "`cat $< | grep -E "(BOOST_FIXTURE_TEST_SUITE\\(|BOOST_AUTO_TEST_SUITE\\()" | cut -d '(' -f 2 | cut -d ',' -f 1 | cut -d ')' -f 1`" -- DEBUG_LOG_OUT > $<.log 2>&1 || (cat $<.log && false)
    
  4. ryanofsky commented at 2:59 PM on February 4, 2022: contributor

    Hmm, this is weird. The assert does come from stderr, but it seems it is not printed if stderr is directed to a file, only if it is directed to a terminal. This suggests t may be a buffering issue, Often output buffering is enabled writing to a file, but not to a terminal. And in this case the assert message is very short and wouldn't exceed a really long buffer.

    Tested adding assert(0) to util_tests/util_datadir test and running:

    # Assert printed to terminal
    wine src/test/test_bitcoin.exe  -l test_suite -t util_tests/util_datadir > out
    
    # No assert
    wine src/test/test_bitcoin.exe  -l test_suite -t util_tests/util_datadir > out 2>&1
    
    # No assert
    wine src/test/test_bitcoin.exe  -l test_suite -t util_tests/util_datadir > out 2> err
    
    # Assert printed to terminal
    wine src/test/test_bitcoin.exe  -l test_suite -t util_tests/util_datadir > out 2> /dev/tty
    

    problem seems to be that assert is not captured if it is directed to a file, but

  5. ryanofsky commented at 3:03 PM on February 4, 2022: contributor

    Piping to another process also doesn't help. Running in a script session does

    # No assert
    wine src/test/test_bitcoin.exe  -l test_suite -t util_tests/util_datadir 2>&1 | tee out
    
    # Assert is printed to terminal and file
    script out -c 'wine src/test/test_bitcoin.exe  -l test_suite -t util_tests/util_datadir'
    
  6. hebasto commented at 3:18 PM on February 16, 2022: member

    Cirrus CI / Win64 build does not seem to print errors from test_bitcoin.exe if an assert statement fails.

    Confirming such misbehavior in the Win64 cross compile CI build. All of other CI builds do print "Assertion failed..." error messages.

  7. hebasto commented at 4:07 PM on February 16, 2022: member

    Further investigation makes me believe that this issue is not Boost-specific, rather MinGW-specific:

    --- a/src/bitcoind.cpp
    +++ b/src/bitcoind.cpp
    @@ -254,6 +254,7 @@ static bool AppInit(NodeContext& node, int argc, char* argv[])
     int main(int argc, char* argv[])
     {
     #ifdef WIN32
    +    assert(false);
         util::WinCmdLineArgs winArgs;
         std::tie(argc, argv) = winArgs.get();
     #endif
    
  8. hebasto commented at 4:35 PM on February 16, 2022: member

    Using strace shows that to print an assertion error, it uses fcntl with a descriptor that is not mentioned in the launch command. Weird...

  9. hebasto commented at 11:33 PM on February 16, 2022: member

    Should fixed in #24363.

  10. hebasto commented at 10:36 AM on February 3, 2023: member

    But the default docker / cirrus output just shows the test_bitcoin.exe process exiting without any information about a failing assert.

    It seems it has no longer the case on the master branch. For example, with the following diff applied:

    --- a/src/test/amount_tests.cpp
    +++ b/src/test/amount_tests.cpp
    @@ -5,6 +5,7 @@
     #include <consensus/amount.h>
     #include <policy/feerate.h>
     
    +#include <cassert>
     #include <limits>
     
     #include <boost/test/unit_test.hpp>
    @@ -13,6 +14,7 @@ BOOST_AUTO_TEST_SUITE(amount_tests)
     
     BOOST_AUTO_TEST_CASE(MoneyRangeTest)
     {
    +    assert(false);
         BOOST_CHECK_EQUAL(MoneyRange(CAmount(-1)), false);
         BOOST_CHECK_EQUAL(MoneyRange(CAmount(0)), true);
         BOOST_CHECK_EQUAL(MoneyRange(CAmount(1)), true);
    

    the CI task output is:

    ...
    test/amount_tests.cpp(15): Entering test case "MoneyRangeTest"
    Assertion failed: false, file test/amount_tests.cpp, line 17
    ...
    
  11. fanquake commented at 11:35 AM on February 3, 2023: member

    So we can close this now then?

  12. hebasto commented at 11:36 AM on February 3, 2023: member

    So we can close this now then?

    Yes, I think.

    cc @ryanofsky

  13. fanquake commented at 11:44 AM on February 3, 2023: member

    Can be re-opened if still an issue.

  14. fanquake closed this on Feb 3, 2023

  15. bitcoin locked this on Feb 3, 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: 2026-04-17 03:13 UTC

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