SChernykh / p2pool

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

Call to p2pool::panic causes segfault #158

Closed kpcyrd closed 2 years ago

kpcyrd commented 2 years ago

There are a few places that call to panic as defined here:

https://github.com/SChernykh/p2pool/blob/d23c46ff845cb9568890d96a380d074592613ce5/src/util.cpp#L50-L61

This causes the program to exit with a segfault like this (even if just used with incorrect arguments):

2022-05-22 21:29:15.9482 Log started
2022-05-22 21:29:15.9484 P2Pool v2.0 (built with GCC/12.1.0 on May 22 2022)
2022-05-22 21:29:15.9484 P2Pool Invalid wallet address. Try "p2pool --help".
2022-05-22 21:29:15.9484 Log stopped
[2]    1275243 IOT instruction (core dumped)  p2pool --host 127.0.0.1 --wallet 
% 

I think this should be a call to exit(1).

SChernykh commented 2 years ago

This function is called when p2pool can't continue running in any way, so it must stop immediately. exit does too many other things before terminating the program: https://en.cppreference.com/w/cpp/utility/program/exit So abort is used instead.

SChernykh commented 2 years ago

Although you have a point that wrong command line options can and should be handled more gracefully.