depends: Patch libevent build to fix IPv6 -rpcbind on Windows #18287

pull luke-jr wants to merge 1 commits into bitcoin:master from luke-jr:fix_libevent_win_ipv6 changing 2 files +17 −0
  1. luke-jr commented at 3:59 am on March 7, 2020: member

    libevent uses getaddrinfo when available, and falls back to gethostbyname Windows has both, but gethostbyname only supports IPv4 libevent fails to detect Windows’s getaddrinfo due to not including the right headers This patches libevent’s configure script to check it correctly

    Upstream issue: https://github.com/libevent/libevent/issues/966

  2. depends: Patch libevent build to fix IPv6 -rpcbind on Windows
    libevent uses getaddrinfo when available, and falls back to gethostbyname
    Windows has both, but gethostbyname only supports IPv4
    libevent fails to detect Windows's getaddrinfo due to not including the right headers
    This patches libevent's configure script to check it correctly
    e918138fd5
  3. fanquake added the label Build system on Mar 7, 2020
  4. fanquake added the label Needs gitian build on Mar 7, 2020
  5. fanquake added the label Windows on Mar 7, 2020
  6. DrahtBot removed the label Needs gitian build on Mar 7, 2020
  7. luke-jr referenced this in commit aa0f3fc376 on Mar 7, 2020
  8. laanwj added the label RPC/REST/ZMQ on Mar 11, 2020
  9. laanwj commented at 2:23 pm on March 11, 2020: member

    Good catch. It’s really sneaky that including a header can make this difference.

    I think it’d be good to have a test for this case to detect regression.

  10. MarcoFalke added the label Needs gitian build on Mar 11, 2020
  11. luke-jr commented at 4:05 pm on March 11, 2020: member
    Who maintains the Windows CI stuff? That’s the only place I can see a test making sense…
  12. MarcoFalke commented at 4:47 pm on March 11, 2020: member
    How would a test case look like? Can’t it be added as a normal unit or functional test?
  13. luke-jr commented at 5:51 pm on March 11, 2020: member
    I think just specifying -rpcbind=::1 would fail at startup. Does AppVeyor run the functional tests?
  14. MarcoFalke commented at 6:36 pm on March 11, 2020: member

    Appveyor uses msvc to compile, not sure if that changes anything. @sipsorcery

    Though, we have a windows cross build that runs the unit tests: https://github.com/bitcoin/bitcoin/blob/58c72880ff70807cf622cdebf1d6273f4041bd2e/ci/test/00_setup_env_win64.sh#L12

  15. sipsorcery commented at 6:56 pm on March 11, 2020: member

    I’ve just tested starting bitcoind built with msvc using:

    ..\src\bitcoind -rpcbind=::1 -rpcallowip=0.0.0.0/0 -debug

    It failed with the relevant log messages being:

    0libevent: event_add: event: 000001F4D284AA20 (fd 1764), EV_READ    call 00007FF6DB2244A0
    12020-03-11T18:48:42Z libevent: win32_add: adding event for 1764
    22020-03-11T18:48:42Z Binding RPC on address ::1 port 8332
    32020-03-11T18:48:42Z libevent: Detected an IPv4 interface
    42020-03-11T18:48:42Z libevent: getaddrinfo: nodename nor servname provided, or not known
    52020-03-11T18:48:42Z Binding RPC on address ::1 port 8332 failed.
    62020-03-11T18:48:42Z Unable to bind any endpoint for RPC server
    72020-03-11T18:48:42Z libevent: event_del: 000001F4D284AA20 (fd 1764), callback 00007FF6DB2244A0
    82020-03-11T18:48:42Z libevent: win32_del: Removing event for 1764
    92020-03-11T18:48:42Z libevent: event_base_free_: 0 events freed
    

    This does appear to support Luke’s diagnosis.

    The patch won’t solve the problem for msvc builds because the libevent dependency isn’t installed with the Bitcoin Core depends scripts (it uses vcpkg in the .appveyor file).

    If it’s possible it would seem sensible to add a unit test that attempts to start bitcoind with the rpc listener on ::1. I can’t recall if the appveyor vm’s have IPv6 enabled or not, I’ll check.

  16. DrahtBot commented at 8:50 am on March 12, 2020: member

    Gitian builds

    File commit d20d5dc824269fff45bb6fc9dbf1a6ce811b8559(master) commit fa9cd0d6e9abdb94cc80a7da33fc5a6ca3d07e00(master and this pull)
    bitcoin-0.19.99-aarch64-linux-gnu-debug.tar.gz 73956d4944191255... 5153f27de9e1bdb0...
    bitcoin-0.19.99-aarch64-linux-gnu.tar.gz fb88fd609c8c1b1c... 68d05a4e1726538a...
    bitcoin-0.19.99-arm-linux-gnueabihf-debug.tar.gz b86040afa2b48137... 63f3136fd23b58cd...
    bitcoin-0.19.99-arm-linux-gnueabihf.tar.gz 21e193b0f898c969... 5fc8d06154eac9ac...
    bitcoin-0.19.99-osx-unsigned.dmg a6be9f0646feef1c... d5b0f35b107edf84...
    bitcoin-0.19.99-osx64.tar.gz 5a94089a3dbc5f3f... 6c38970879bed33c...
    bitcoin-0.19.99-riscv64-linux-gnu-debug.tar.gz c0716e8ef89e4725... 7b5144f87f4826e4...
    bitcoin-0.19.99-riscv64-linux-gnu.tar.gz bdc5d76d88c0e8e6... 7e64bd3645fc7770...
    bitcoin-0.19.99-win64-debug.zip 7d5c7682cd2045ac... b1e6eb754222ddfb...
    bitcoin-0.19.99-win64-setup-unsigned.exe 4c39acb810bed5ec... f00f9502110f5d68...
    bitcoin-0.19.99-win64.zip 997e3870a32aa396... bccc5740f929692a...
    bitcoin-0.19.99-x86_64-linux-gnu-debug.tar.gz d7558a4738ae2d5b... 2c0017a385697b18...
    bitcoin-0.19.99-x86_64-linux-gnu.tar.gz c590269f431ae2c7... d8cc2df7c7b421ff...
    bitcoin-0.19.99.tar.gz 00d9de8fe9c555a8... b021e8c901c7f711...
    bitcoin-core-linux-0.20-res.yml 33781663516c3d60... a3d2a9b40285a29e...
    bitcoin-core-osx-0.20-res.yml 7f84fbc82c109580... 7a7bd3ed3cd8765a...
    bitcoin-core-win-0.20-res.yml a189b51cd52c859b... cd9dfedefa2a3678...
    linux-build.log 9a596858a2901993... b4e5b0ee54840c22...
    osx-build.log e57b1e14546f1b12... adf8a07151993479...
    win-build.log 145b30399f10aeb9... 062b9ed339740d12...
    bitcoin-core-linux-0.20-res.yml.diff 24d88d8542fd99fe...
    bitcoin-core-osx-0.20-res.yml.diff 85aa4477ed2530e5...
    bitcoin-core-win-0.20-res.yml.diff 901764e9f9fb15d1...
    linux-build.log.diff 160ec3d126e7b5c3...
    osx-build.log.diff 10cfa58da5449f7d...
    win-build.log.diff 85d2d8eca1349b53...
  17. DrahtBot removed the label Needs gitian build on Mar 12, 2020
  18. sipsorcery commented at 10:29 pm on March 19, 2020: member

    @luke-jr I’m attempting to verify this fix but so far the Windows executable I produce still fails to bind the RPC port on ::1.

    It looks like the patch is working insofar as if I do:

    0cd depends
    1make libevent
    

    the output does indicate getaddrinfo is available.

    0checking for getservbyname... yes
    1checking for getaddrinfo... yes
    2checking for F_SETFD in fcntl.h... yes
    3checking for select... yes
    

    I’ll keep digging but if you know of any obvious things I should check I’d be happy to hear them.

  19. laanwj added the label Needs backport (0.20) on Apr 23, 2020
  20. fanquake commented at 10:42 am on May 13, 2020: member

    This patch (part of https://github.com/libevent/libevent/pull/969/commits/6d54be2cc078351b4ce1e469bedc4a976f4e3636) looks ok and the inclusion of the additional headers definitely fixes libevents detection of getaddrinfo. Note that the same headers are also used here: https://github.com/libevent/libevent/blob/4c908dde58ef780eeefcc9df4db3063ca62ea862/include/event2/util.h#L65

    However I have also tried to verify the fix, and after cross-compiling this PR and taking bitcoind.exe into a Windows 10 VM I cannot get it to run using the same command as @sipsorcery. i.e bitcoind.exe -rpcbind=::1 -rpcallowip=0.0.0.0/0 -debug.

    Obviously there is an issue here, but at this point I don’t think this can be a blocker for 0.20.0 unless someone can verify a fix.

  21. MarcoFalke added this to the milestone 0.20.0 on May 13, 2020
  22. MarcoFalke deleted a comment on May 13, 2020
  23. fanquake removed this from the milestone 0.20.0 on May 14, 2020
  24. fanquake added this to the milestone 0.20.1 on May 14, 2020
  25. fanquake removed the label Needs backport (0.20) on May 14, 2020
  26. fanquake commented at 4:53 am on June 25, 2020: member
    Going to close this in favour of #19375, which includes this change.
  27. fanquake closed this on Jun 25, 2020

  28. fanquake removed this from the milestone 0.20.1 on Jun 25, 2020
  29. laanwj referenced this in commit e491e55646 on Jul 1, 2020
  30. DrahtBot locked this on Feb 15, 2022

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-12-22 09:12 UTC

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