SChernykh / p2pool

Decentralized pool for Monero mining
GNU General Public License v3.0
1.08k stars 128 forks source link

abort on close handle when starting up #195

Closed widgetfly closed 2 years ago

widgetfly commented 2 years ago

I recently upgraded to V2.2.1 after having good results with multiple previous versions running on MacOS. My ports are opened up (18080 and 37889), double checked, and brew is updated as well. My monerod is running from within the Monero-GUI version 0.18.0.0-release

When I launch using:

$ ./p2pool --host 127.0.0.1 --wallet XXXXX

Get the following output and an abort:

2022-07-31 19:14:02.9881 Log started 2022-07-31 19:14:02.9892 P2Pool v2.2.1 (built with clang/12.0.5 (clang-1205.0.22.9) on Jul 31 2022) 2022-07-31 19:14:02.9895 SideChain network type = mainnet 2022-07-31 19:14:02.9895 SideChain using default config 2022-07-31 19:14:02.9895 SideChain pool name = default 2022-07-31 19:14:02.9895 SideChain block time = 10 seconds 2022-07-31 19:14:02.9895 SideChain min diff = 100000 2022-07-31 19:14:02.9895 SideChain PPLNS window = 2160 blocks 2022-07-31 19:14:02.9896 SideChain uncle penalty = 20% 2022-07-31 19:14:02.9896 SideChain generating consensus ID 2022-07-31 19:14:02.9896 SideChain consensus ID = 22af7ee7****4407f918 2022-07-31 19:14:03.3361 RandomX_Hasher allocated 2592 MB 2022-07-31 19:14:03.3385 ConsoleCommands event loop started Assertion failed: (!uv__is_closing(handle)), function uv_poll_start, file poll.c, line 126. zsh: abort ./p2pool --host 127.0.0.1 --wallet

Tried restarting, rebuilding from scratch, etc. With same results.

Some quick searching indicates this is likely a close of an already closed handle but I haven't sorted out the code as to where that might be happening.

I didn't have this issue prior to upgrading to V2.2.1 and 0.18.0.0.

widgetfly commented 2 years ago

Here's a backtrace of where this is happening:

Target 0: (p2pool) stopped. (lldb) bt thread 1, queue = 'com.apple.main-thread', stop reason = hit program assert frame 0: 0x00007ff80748d00e libsystem_kernel.dylib__pthread_kill + 10 frame 1: 0x00007ff8074c31ff libsystem_pthread.dylibpthread_kill + 263 frame 2: 0x00007ff80740ed24 libsystem_c.dylibabort + 123 frame 3: 0x00007ff80740e0cb libsystem_c.dylibassert_rtn + 314 frame 4: 0x000000010037afd2 libuv.1.dylibuv_poll_start.cold.2 + 33 frame 5: 0x0000000100370257 libuv.1.dylibuv_poll_start + 213 frame 6: 0x00000001000328ff p2poolp2pool::JSONRPCRequest::CurlContext::on_socket(void*, int, int) + 559 frame 7: 0x0000000100032449 p2poolp2pool::JSONRPCRequest::CurlContext::socket_func(void, int, int, void, void) + 25 frame 8: 0x00007ff81c23e895 libcurl.4.dylibsinglesocket + 519 frame 9: 0x00007ff81c2410fb libcurl.4.dylibmulti_socket + 380 frame 10: 0x00007ff81c241190 libcurl.4.dylibcurl_multi_socket_action + 38 frame 11: 0x0000000100032b40 p2poolp2pool::JSONRPCRequest::CurlContext::curl_perform(uv_poll_s, int, int) + 528 frame 12: 0x0000000100379d9f libuv.1.dylib`uvio_poll + 2075 frame 13: 0x0000000100369cd3 libuv.1.dylibuv_run + 282 frame 14: 0x000000010007254b p2poolp2pool::p2pool::run() + 1899 frame 15: 0x000000010003686f p2poolmain + 319 frame 16: 0x000000010018152e dyldstart + 462

SChernykh commented 2 years ago

What is libuv's and libcurl's version on your system? If you run the official v2.2.1 MacOS binary, does it crash in the same way?

widgetfly commented 2 years ago

When I use the release 2.2.1 build (after weaving the MacOS security checks), it runs without a problem.

My version is using the libuv provided by brew as per the build instructions.

When I type the command:

% brew info libuv

I get output:

libuv: stable 1.44.2 (bottled), HEAD Multi-platform support library with a focus on asynchronous I/O https://libuv.org /usr/local/Cellar/libuv/1.44.2 (50 files, 3.5MB) * Poured from bottle on 2022-07-31 at 12:13:05 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/libuv.rb License: MIT ==> Dependencies Build: autoconf ✘, automake ✘, libtool ✘, pkg-config ✘, sphinx-doc ✘ ==> Options --HEAD Install HEAD version ==> Analytics install: 411,118 (30 days), 1,053,221 (90 days), 3,669,610 (365 days) install-on-request: 5,948 (30 days), 11,775 (90 days), 42,860 (365 days) build-error: 23 (30 days)

Thanks for getting back so quickly.

SChernykh commented 2 years ago

Release binary uses libuv 1.44.1, maybe something changed between these two versions that needs fixing on p2pool side.

SChernykh commented 2 years ago

I can't reproduce it on Windows with the latest libuv code, and I don't have MacOS system to test.

amebru commented 2 years ago

Same issue here. The brew release (2.2.1) errors on startup but the official 2.2.1 release from GitHub runs fine.

specs: Mac OS Monterey 12.5 Apple M1 Pro Chip (ARM)

SChernykh commented 2 years ago

@amybruno What does brew info libuv and brew info libcurl say?

SChernykh commented 2 years ago

@widgetfly @amybruno can you build the latest code and try again? I added some more checks and logging to the place where it crashes for you.

widgetfly commented 2 years ago

I did a git pull and tried again. It seems to run now, but doesn't fire up (that is, it doesn't abort but also doesn't start allocating tasks to rigs). Here's the log output:

2022-08-06 14:33:30.5058 Log started 2022-08-06 14:33:30.5070 P2Pool v2.2.1 (built with clang/12.0.5 (clang-1205.0.22.9) on Jul 31 2022) 2022-08-06 14:33:30.5073 SideChain network type = mainnet 2022-08-06 14:33:30.5073 SideChain using default config 2022-08-06 14:33:30.5073 SideChain pool name = default 2022-08-06 14:33:30.5073 SideChain block time = 10 seconds 2022-08-06 14:33:30.5073 SideChain min diff = 100000 2022-08-06 14:33:30.5073 SideChain PPLNS window = 2160 blocks 2022-08-06 14:33:30.5073 SideChain uncle penalty = 20% 2022-08-06 14:33:30.5073 SideChain generating consensus ID 2022-08-06 14:33:30.5074 SideChain consensus ID = 22af7ee7****4407f918 2022-08-06 14:33:37.8853 RandomX_Hasher couldn't allocate RandomX dataset using large pages 2022-08-06 14:33:38.0492 RandomX_Hasher allocated 2592 MB 2022-08-06 14:33:38.0514 ConsoleCommands event loop started 2022-08-06 14:33:38.0594 JSONRPCRequest Poll handle is closing, can't process socket action 2

SChernykh commented 2 years ago

action 2

@widgetfly this is interesting, I never get 2 in my testing there. What's the exact version of libcurl that you use? brew info libcurl?

widgetfly commented 2 years ago

This gave a strange answer:

% brew info libcurl Error: No available formula with the name "libcurl". Did you mean libucl, libcue, libcdr or libcerf? ==> Searching for a previously deleted formula (in the last month)... Error: No previously deleted formula found.

I do see a libcurl down in the git tree under external both src and lib (Debug and Release). For grins, I tried the following:

% brew info curl curl: stable 7.84.0 (bottled), HEAD [keg-only] Get a file from an HTTP, HTTPS or FTP server https://curl.se Not installed From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/curl.rb License: curl ==> Dependencies Build: pkg-config ✘ Required: brotli ✘, libidn2 ✘, libnghttp2 ✘, libssh2 ✘, openldap ✘, openssl@1.1 ✘, rtmpdump ✘, zstd ✘ ==> Options --HEAD Install HEAD version ==> Caveats curl is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and installing another version in parallel can cause all kinds of trouble.

==> Analytics install: 159,259 (30 days), 521,282 (90 days), 1,948,321 (365 days) install-on-request: 82,291 (30 days), 263,061 (90 days), 963,832 (365 days) build-error: 179 (30 days)

SChernykh commented 2 years ago

@widgetfly @amybruno This is fixed in https://github.com/SChernykh/p2pool/commit/bde5b19c77f5b0406cd104224dd1a25463975ca0