SChernykh / p2pool

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

p2pool v3.3 fail to start on centos7 #262

Closed 8lazo8 closed 1 year ago

8lazo8 commented 1 year ago

After updating to v3.3 from 3.2 the service fails to start. I used the zipped binary for linux.

In p2pool.log it hangs at this phase:

NOTICE 2023-05-01 12:16:36.7118 Log started NOTICE 2023-05-01 12:16:36.7176 P2Pool v3.3 (built with GCC/11.2.1 on Apr 30 2023) NOTICE 2023-05-01 12:16:36.7185 SideChain network type = mainnet NOTICE 2023-05-01 12:16:36.7185 SideChain using default config NOTICE 2023-05-01 12:16:36.7185 SideChain pool name = default NOTICE 2023-05-01 12:16:36.7185 SideChain block time = 10 seconds NOTICE 2023-05-01 12:16:36.7185 SideChain min diff = 100000 NOTICE 2023-05-01 12:16:36.7185 SideChain PPLNS window = 2160 blocks NOTICE 2023-05-01 12:16:36.7185 SideChain uncle penalty = 20% NOTICE 2023-05-01 12:16:36.7186 SideChain generating consensus ID NOTICE 2023-05-01 12:16:36.7186 SideChain consensus ID = 22af7ee7****4407f918 WARNING 2023-05-01 12:16:36.7246 RandomX_Hasher couldn't allocate RandomX dataset using large pages WARNING 2023-05-01 12:16:36.7248 RandomX_Hasher couldn't allocate RandomX cache using large pages WARNING 2023-05-01 12:16:36.7250 RandomX_Hasher couldn't allocate RandomX cache using large pages NOTICE 2023-05-01 12:16:36.7250 RandomX_Hasher allocated 2592 MB NOTICE 2023-05-01 12:16:36.7268 ConsoleCommands uv_guess_handle returned 17 ERROR 2023-05-01 12:16:36.7268 ConsoleCommands tty or named pipe is not available ERROR 2023-05-01 12:16:36.7268 TCPServer TCP wasn't shutdown properly NOTICE 2023-05-01 12:16:36.7275 Util UPnP: Started scanning for UPnP IGD devices

In messages I see the following: May 1 14:16:36 centos-7 systemd: Started P2Pool. May 1 14:16:36 centos-7 kernel: p2pool[9185]: segfault at 38 ip 000000000060d2e9 sp 00007ffcae898d70 error 4 in p2pool[401000+215000] May 1 14:16:37 centos-7 abrt-hook-ccpp: Process 9185 (p2pool) of user 0 killed by SIGSEGV - ignoring (repeated crash) May 1 14:16:37 centos-7 systemd: p2pool.service: main process exited, code=dumped, status=11/SEGV May 1 14:16:37 centos-7 systemd: Unit p2pool.service entered failed state. May 1 14:16:37 centos-7 systemd: p2pool.service failed. May 1 14:16:37 centos-7 systemd: p2pool.service holdoff time over, scheduling restart. May 1 14:16:37 centos-7 systemd: Stopped P2Pool. May 1 14:16:37 centos-7 systemd: Started P2Pool. May 1 14:16:37 centos-7 kernel: p2pool[9197]: segfault at 38 ip 000000000060d2e9 sp 00007fff96ed9d30 error 4 in p2pool[401000+215000] May 1 14:16:37 centos-7 abrt-hook-ccpp: Process 9197 (p2pool) of user 0 killed by SIGSEGV - ignoring (repeated crash) May 1 14:16:37 centos-7 systemd: p2pool.service: main process exited, code=dumped, status=11/SEGV May 1 14:16:37 centos-7 systemd: Unit p2pool.service entered failed state. May 1 14:16:37 centos-7 systemd: p2pool.service failed. May 1 14:16:37 centos-7 systemd: p2pool.service holdoff time over, scheduling restart. May 1 14:16:37 centos-7 systemd: Stopped P2Pool. May 1 14:16:37 centos-7 systemd: start request repeated too quickly for p2pool.service May 1 14:16:37 centos-7 systemd: Failed to start P2Pool. May 1 14:16:37 centos-7 systemd: Unit p2pool.service entered failed state. May 1 14:16:37 centos-7 systemd: p2pool.service failed.

I rolled back to p2pool v3.2 and it works fine. In general I proceeded with the upgrqade as always in the past. Stopping the service, replacing the binary, starting it again.

jameswillhoite commented 1 year ago

Same with Ubuntu 22.04.2

dieg0nob commented 1 year ago

same with ubuntu 20.04.2

hinto-janai commented 1 year ago

Confirming bug in v3.3.

If there isn't a TTY/named pipe to attach to, p2pool will crash.

https://github.com/monero-project/monero-gui/pull/4164 should probably be closed since most Monero-GUI users aren't starting it from a terminal.

jameswillhoite commented 1 year ago

I was able to get it to work.

create the socket file the same name as the service file. I named mine p2pool-mini because I run the mini chain.

p2pool-mini.service

[Unit] Description=P2Pool XMR - Mini After=network-online.target monerod.service Requires=p2pool-mini.socket

[Service]

Type=exec

User=p2pool Group=p2pool WorkingDirectory=/opt/p2pool Sockets=p2pool-mini.socket StandardInput=socket StandardOutput=journal StandardError=journal

Type=simple

ExecStart=/opt/p2pool/p2pool --host 127.0.0.1 --mini --loglevel 1 --stratum 0.0.0.0:3345 --wallet --light-mode --no-randomx --no-upnp

Restart=always

[Install] WantedBy=multi-user.target

The p2pool-mini.socket

[Unit] Description=Command FIFO for p2pool daemon

[Socket] ListenFIFO=/opt/p2pool/p2pool-mini.control DirectoryMode=0755 SocketMode=0666 SocketUser=p2pool SocketGroup=p2pool RemoveOnStop=true

I keep everything in /opt/p2pool so that is why I created the working directory in /opt/p2pool.

when you create the p2pool-mini.sock file you need to load it into systemd with

sudo ln -s file/path/to/p2pool-mini.socket /etc/systemd/system/p2pool-mini.socket sudo systemctl daemon-reload sudo systemctl start p2pool-mini-service

jameswillhoite commented 1 year ago

I kept getting the error May 01 10:35:59 monero-qw1 systemd[1]: p2pool.socket: Socket service p2pool.service not loaded, refusing. in the journal so that lead me to believe the socket had to be named the same when I added to systemctl. I also think that in the .socket file the ListenFIFO needed to be the absolute path.

I also realized that this doesn't solve the issue at hand (No named pipe) but in my case I do want to use it, and this was how I was able to get the named pipe to work as the README did not work as a copy paste.

DeeDeeRanged commented 1 year ago

What do you have in your p2pool-mini.control file? You have already used mini on the Exec line, as that defines if you are using mini or not, in your p2pool-mini.service so there is no need to add mini to every file.

jameswillhoite commented 1 year ago

What do you have in your p2pool-mini.control file?

That is what the socket is. I can call echo "status" > p2pool-mini.control and it will print out the status info into my p2pool.log file

SChernykh commented 1 year ago

Can any of you compile it from sources and get callstack of this crash? I can't reproduce it here.

jameswillhoite commented 1 year ago

When I have a little free time I will. Got this error originally by download release for linux-x64, tar -xvf, cp to /opt/p2pool/p2pool (for me, where my p2pool is installed) then started my original service file. I had not created/modified the service file at all. Did not create the socket file, did not add socket file to systemd.

Original Service file before adding the Named Socket for use

p2pool-mini.service

[Unit] Description=P2Pool XMR - Mini After=network-online.target monerod.service

[Service] User=monero Group=monero WorkingDirectory=/opt/p2pool

Type=simple

ExecStart=/opt/p2pool/p2pool --host 127.0.0.1 --mini --loglevel 1 --stratum 0.0.0.0:3345 --wallet --light-mode --no-randomx --no-upnp

Restart=always

[Install] WantedBy=multi-user.target

8lazo8 commented 1 year ago

Can any of you compile it from sources and get callstack of this crash? I can't reproduce it here.

I'm not able to do that. :/

However I'm willing to help doing it if I can get instructions.

DeeDeeRanged commented 1 year ago

If it helps dmesg throws this in for p2pool.

p2pool[6197]: segfault at 38 ip 000000000060d2e9 sp 00007ffccb4aa460 error 4 in p2pool[401000+215000] likely on CPU 1 (core 1, socket 0) [12355.667340] Code: aa 0c 00 00 48 8d 74 24 0c bf 01 00 00 00 e8 b2 0a 00 00 83 7c 24 0c 00 75 09 31 f6 31 ff e8 a2 0a 00 00 45 31 e4 4c 8d 73 38 <8b> 73 38 85 f6 75 19 8b 7c 24 0c 31 f6 e8 89 0a 00 00 41 83 fc 6e

hinto-janai commented 1 year ago

@SChernykh I think it's a pthread issue. I can only reproduce on some machines as well.

Crashes occur starting from https://github.com/SChernykh/p2pool/commit/196b27f3b21bcf8096ecee1e3b7d089ded1fa30f.

This is from the current head https://github.com/SChernykh/p2pool/commit/fcb62894a55c4eb00e662ab81d92a2742635ad74:

Thread 1 "p2pool" received signal SIGSEGV, Segmentation fault.
__pthread_clockjoin_ex (threadid=0, thread_return=0x0, clockid=0, abstime=0x0, block=true) at pthread_join_common.c:43
43   if (INVALID_NOT_TERMINATED_TD_P (pd))                                                                                                                                                     
(gdb) bt
#0  __pthread_clockjoin_ex (threadid=0, thread_return=0x0, clockid=0, abstime=0x0, block=true) at pthread_join_common.c:43
#1  0x00007ffff7ed1243 in uv_thread_join () from /usr/lib/libuv.so.1
#2  0x0000555555697d46 in p2pool::TCPServer::~TCPServer() ()
#3  0x00005555555e112b in ?? ()
#4  0x000055555563e7fc in p2pool::p2pool::p2pool(int, char**) ()
#5  0x00005555555e9187 in main ()

You can force p2pool to start without a TTY/pipe with:

nohup ./p2pool [...]

or

gdb nohup

(gdb) run ./p2pool [...]
SChernykh commented 1 year ago

It doesn't crash for me with nohup, and even when manually triggering tty or named pipe is not available code path. But if it crashes inside uv_thread_join, I can try to figure out why.

SChernykh commented 1 year ago

https://github.com/SChernykh/p2pool/commit/8a222d5e750d70b039727c52c06bc0b30378a8e3 should fix it.

hinto-janai commented 1 year ago

Terminal + nohup and Monero-GUI both work with https://github.com/SChernykh/p2pool/commit/8a222d5e750d70b039727c52c06bc0b30378a8e3.

APN-Pucky commented 1 year ago

Gentoo + OpenRC works with https://github.com/SChernykh/p2pool/commit/8a222d5e750d70b039727c52c06bc0b30378a8e3 now too.