Skip to content

conftest.exe error during make of depends on Windows Subsystem for Linux #17277

Closed

Description

@mmortal03

Expected behavior
Making the Bitcoin depends on Windows Subsystem for Linux (Ubuntu 18.04) should complete without error.

Actual behavior
I'm getting prompted with a conftest.exe application error (see below for screenshot) during the make of the depends. This blocks further progress of make until I click the prompt. It doesn't seem to impact the ultimate build result, but it wastes time, blocking the remaining process while waiting for user input. I assume WSL is incorrectly trying to run this executable in Windows. The error occurs during the "checking for clock_gettime monotonic clock..." step, or shortly thereafter. I verified that no extraneous paths have been added to my $PATH variable.

To reproduce
1.) In Windows, open bash prompt of Windows Subsystem for Linux (Ubuntu 18.04).
2.) Install the required packages to build Bitcoin, set the default mingw32 g++ compiler option to posix, etc. (In other words, do all the standard preparation steps for compiling Bitcoin on Windows.)
3..) Run the following:

PATH=$(echo "$PATH" | sed -e 's/:\/mnt.*//g') 
//this strips out problematic Windows %PATH% imported var (see doc/build-windows.md)

git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin/depends
make HOST=x86_64-w64-mingw32

4.) Now wait until it gets to "checking for clock_gettime monotonic clock...", and then you will get the following application error prompt:
conftest

Activity

  1. sipsorcery commented on Nov 4, 2019

    @sipsorcery
    Contributor

    I failed to replicate this with WSL and Ubuntu 18.04.

    A quick Google found some articles where the conftest.exe generated by the mingw configure script gets flagged by anti-virus programs. Do you have an AV program that could be the culprit?

  2. mmortal03 commented on Nov 5, 2019

    @mmortal03
    Author

    I failed to replicate this with WSL and Ubuntu 18.04.

    A quick Google found some articles where the conftest.exe generated by the mingw configure script gets flagged by anti-virus programs. Do you have an AV program that could be the culprit?

    No, only the regular "Windows Security" virus protection that's built in to Windows 10. Let me do some further testing on another machine and see if I can reproduce it and compare it to the offending machine.

  3. laanwj commented on Nov 5, 2019

    @laanwj
    Member

    Please upload your config.log somewhere, it might give a clue why you end up with a conftest.exe instead of a Linux executable.

  4. mmortal03 commented on Nov 6, 2019

    @mmortal03
    Author

    Please upload your config.log somewhere, it might give a clue why you end up with a conftest.exe instead of a Linux executable.

    Should there be a config.log? This is occurring in the make of the depends folder, before I get to the configure step.

  5. laanwj commented on Nov 6, 2019

    @laanwj
    Member

    Should there be a config.log? This is occurring in the make of the depends folder, before I get to the configure step.

    There's always a config.log when configure runs.

    Also it would be good to know what dependency is generating this error! It's useful information at least that it's not bitcoin's own configure script.

  6. mmortal03 commented on Nov 6, 2019

    @mmortal03
    Author

    It seems there must be a part of the make process (of the dependencies) that removes the config.log(s) after it completes. I did a file search while it was running and did see a config.log present under, for example, a zeromq subfolder, but this file disappeared once everything was completed. I'll capture the console output and monitor it to see if I can better pinpoint the package where this is happening.

  7. mmortal03 commented on Nov 6, 2019

    @mmortal03
    Author

    Okay, I think I found it. It's happening during the configuring of bdb. The error happens after the following bdb config.log line 5842, where the console output is: "checking for clock_gettime monotonic clock". I'm outside of my knowledge as far as what might be going wrong here.
    bdb_config.log

  8. laanwj commented on Nov 6, 2019

    @laanwj
    Member

    that helps!
    berkeleydb apparently checks whether it's cross-compiling by trying to execute the build output

    configure:4860: checking whether we are cross compiling
    configure:4868: x86_64-w64-mingw32-gcc -o conftest.exe -pipe -O2     -I/home/mmortal03/bitcoin/depends/x86_64-w64-mingw32/include   -DUNICODE -D_UNICODE   -L/home/mmortal03/bitcoin/depends/x86_64-w64-mingw32/lib     conftest.c  >&5
    configure:4872: $? = 0
    configure:4879: ./conftest.exe
    configure:4883: $? = 0
    configure:4898: result: no
    

    this is quite unusual; it should derive this from command line settings only
    then again the build system for bdb 4.8 is old as the hills

  9. mmortal03 commented on Nov 7, 2019

    @mmortal03
    Author

    Definitely interesting, so the next question is: why does its execution error out on my machine, whereas it doesn't on sipsorcery's machine?

    I noticed that the line @laanwj referenced is not the only time where ./conftest.exe is run, so, might there be something specific to the "checking for clock_gettime monotonic clock" test that's causing the executable to fail, only at this step?

    @sipsorcery , what version of Windows 10 are you running? I'm on 1903. I came across the following, but I don't know if it applies or not (and it's unclear whether it's been fixed in the latest Windows 10 builds or not): microsoft/WSL#3840

  10. sipsorcery commented on Nov 7, 2019

    @sipsorcery
    Contributor

    @mmortal03 I'm on Windows 10 Pro Insider Preview Build 18956.rs_prerelease.190803-1414.

    I switched to the Windows Insider Ring about 6 months ago and prior to that was able to build Bitcoin Core on the standard release version of Windows 10.

    Are you using WSL 1 or 2? There are some fundamental changes between them.

     wsl -l -v
      NAME            STATE           VERSION
    * Ubuntu-18.04    Running         1
    
  11. mmortal03 commented on Nov 7, 2019

    @mmortal03
    Author

    @sipsorcery I just tried that from the Windows command line, as well as PowerShell, but my wsl command doesn't have that verbose argument as an option, it only has the list argument, so I can't provide the same output. I would suspect I'm on version 1, though.

  12. laanwj commented on Nov 7, 2019

    @laanwj
    Member

    It'd be good to ensure all updates (windows and ubuntu, and WSL) are up to date first, to avoid spending time chasing ghosts.

    might there be something specific to the "checking for clock_gettime monotonic clock" test that's causing the executable to fail, only at this step?

    Could be, yes. You could try to extract test code it's trying to compile and run at that step, compile it yourself and try to figure out why it produces an invalid exe.

  13. 2 remaining items

  14. mmortal03 commented on Nov 8, 2019

    @mmortal03
    Author

    In terms of going the static linking route, I came across the suggestion of the following parameters which do seem to work around the issue of needing libwinpthread-1.dll to be present:

    x86_64-w64-mingw32-gcc -o conftest.exe conftest.c -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,--no-whole-archive

    Source: https://stackoverflow.com/a/43402308/4438237

    Also important, the following distinguishes between this issue in the mingw-w64 project and what MinGW.org does: metaeducation/revolt#624 (comment)

  15. billygarrison commented on Mar 8, 2020

    @billygarrison
    Contributor

    I have the same issue, which also appears at the checking for clock_gettime monotonic clock point.

    Windows 10 build 18363, WSL (not WSL 2). I upgraded Ubuntu from 16.04 to 18.04 and then followed the instructions at https://github.com/bitcoin/bitcoin/blob/master/doc/build-windows.md.

    The error message that popped up was:

    The code execution cannot proceed because libwinpthread-1.dll was not found. Reinstalling the program may fix this problem.


    @mmortal03, which directory did you place the .dll in? (which executable are you referring to in the following?):

    I went and grabbed the libwinpthread-1.dll from /usr/x86_64-w64-mingw32/lib/ and placed it in the same directory as the executable, which seems to fix the problem

  16. billygarrison commented on Mar 8, 2020

    @billygarrison
    Contributor

    I should add that after closing the error popup, the command seemed to continue successfully.

    Following the build-windows.md instructions I was able to successfully do the following commands:

    ./autogen.sh
    CONFIG_SITE=$PWD/depends/x86_64-w64-mingw32/share/config.site ./configure --prefix=/
    make
    make install DESTDIR=/mnt/c/bitcoin
    

    But when I ran make check there was a failure, which may or may not be related to the DLL error in the depends make command:

    ********* Start testing of WalletTests *********
    Config: Using QtTest library 5.9.8, Qt 5.9.8 (x86_64-little_endian-llp64 static release build; by GCC 7.3-posix 20180312)
    PASS   : WalletTests::initTestCase()
    QDEBUG : WalletTests::walletTests() TransactionTablePriv::refreshWallet
    QWARN  : WalletTests::walletTests() This plugin does not support propagateSizeHints()
    A crash occurred in \\wsl$\Ubuntu\usr\src\bitcoin\src\qt\test\test_bitcoin-qt.exe.
    Function time: 1440ms Total time: 1441ms
    
    Exception address: 0x0000000001568e55
    Exception code   : 0xc0000005
    
    Stack:
    #  1: Unable to obtain symbol
    #  2: UnhandledExceptionFilter() - 0x00007fff0a61f4b0
    #  3: memset() - 0x00007fff0c8c3000
    #  4: _C_specific_handler() - 0x00007fff0c8ac640
    #  5: _chkstk() - 0x00007fff0c8c1100
    #  6: RtlRaiseException() - 0x00007fff0c889ef0
    #  7: KiUserExceptionDispatcher() - 0x00007fff0c8bfe60
    #  8: Unable to obtain symbol
    #  9: Unable to obtain symbol
    # 10: Unable to obtain symbol
    # 11: Unable to obtain symbol
    # 12: Unable to obtain symbol
    # 13: Unable to obtain symbol
    # 14: Unable to obtain symbol
    # 15: Unable to obtain symbol
    # 16: Unable to obtain symbol
    # 17: Unable to obtain symbol
    # 18: Unable to obtain symbol
    # 19: Unable to obtain symbol
    # 20: Unable to obtain symbol
    # 21: Unable to obtain symbol
    # 22: Unable to obtain symbol
    # 23: Unable to obtain symbol
    # 24: Unable to obtain symbol
    # 25: Unable to obtain symbol
    # 26: Unable to obtain symbol
    # 27: Unable to obtain symbol
    # 28: Unable to obtain symbol
    # 29: Unable to obtain symbol
    # 30: secp256k1_ecdsa_recover() - 0x0000000001e309a0
    # 31: Unable to obtain symbol
    # 32: Unable to obtain symbol
    # 33: BaseThreadInitThunk() - 0x00007fff0b8a7bc0
    # 34: RtlUserThreadStart() - 0x00007fff0c88ceb0
    
    FAIL qt/test/test_bitcoin-qt.exe (exit status: 5)
    
  17. mmortal03 commented on Mar 8, 2020

    @mmortal03
    Author

    @mmortal03, which directory did you place the .dll in? (which executable are you referring to in the following?):

    I went and grabbed the libwinpthread-1.dll from /usr/x86_64-w64-mingw32/lib/ and placed it in the same directory as the executable, which seems to fix the problem

    There might be a way to automatically inject the dll into the proper directory at compile time, but I can't say what exact modifications that would entail, because I think the directories are generated during the compilation process. I'm pretty sure I was just reporting that it fixed the error in the isolated sense of putting the two together in their own directory -- dealing with the issue at compile time still needs a fix.

  18. billygarrison commented on Jun 21, 2020

    @billygarrison
    Contributor

    @mmortal03 @laanwj I have found a working solution to this problem in my case (#18348)

    Using sudo make HOST=x86_64-w64-mingw32 instead of just make HOST=x86_64-w64-mingw32 fixes the problem. No idea why.

  19. mmortal03 commented on Jun 22, 2020

    @mmortal03
    Author

    @mmortal03 @laanwj I have found a working solution to this problem in my case (#18348)

    Using sudo make HOST=x86_64-w64-mingw32 instead of just make HOST=x86_64-w64-mingw32 fixes the problem. No idea why.

    Yeah, I've seen cases of this sort of thing working in various respects, even though people will tell you that we shouldn't be putting sudo on such compilation commands. I haven't tested this lately. I should try compiling 0.20.0 and see if anything different happens.

  20. mmortal03 commented on Jun 23, 2020

    @mmortal03
    Author

    @billygarrison I just tested it, and can confirm that using sudo gets around it for me, as well. Hopefully someone more knowledgeable can figure out why this is the case and fix it.

  21. billygarrison commented on Jun 29, 2020

    @billygarrison
    Contributor

    @sipsorcery came up with an easy-to-implement workaround #18348 (comment)

  22. mmortal03 commented on Jun 30, 2020

    @mmortal03
    Author

    @sipsorcery came up with an easy-to-implement workaround #18348 (comment)

    Thanks! I can confirm that this works around the the issue.

    @laanwj , should we close this and open a new issue for the long term, automated fix?

  23. added a commit that references this issue on Jul 1, 2020
  24. laanwj commented on Jul 1, 2020

    @laanwj
    Member

    I don't think it's possible to fix this on our side. #19408 (comment) is probably right that this issue is common to all autoconf projects.

  25. mmortal03 commented on Jul 2, 2020

    @mmortal03
    Author

    Yep, I'll close it, then. I guess someone could post a bug report to [email protected], though I did a quick search through their archives regarding Windows and someone stated, "MS-Windows is not our platform of choice and questions involving it are lower priority." Maybe it's not up the GNU gang and it's the Microsoft WSL people who need to come up with a more elegant default handling of binfmt_misc cases. It's beyond my paygrade, lol.

  26. added a commit that references this issue on Dec 7, 2020
  27. locked as resolved and limited conversation to collaborators on Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions