mtve / yazecminer

yet another ZEC miner
43 stars 47 forks source link

incr_text can not be called when the incremental parser already started parsing #8

Closed leto closed 7 years ago

leto commented 7 years ago

This bug is kind of fun:

incr_text can not be called when the incremental parser already started parsing at lib/AnyEvent/Handle.pm line 1765.
[2]+  Exit 255                perl duke_server.pl

This happens when server1.pl and server2.pl share the same lib/ directory. It does not happen for a long time, which leads me to believe it is a race condition that is not tickled easily.

I understand if your response is "don't do that" but I figured I should tell you.

 perl -v

This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-linux-gnu-thread-multi
(with 58 registered patches, see perl -V for more detail)

Linux 4.9.36-x86_64-linode85 #1 SMP Thu Jul 6 15:31:23 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

mtve commented 7 years ago

i do cut some corners when using AnyEvent, so i have some guesses on what happened. need time to investigate.

would you please provide output of:

perl -MJSON::XS -wle 'print $JSON::XS::VERSION'
perl -MJSON::PP -wle 'print $JSON::PP::VERSION'

thanks in advance!

leto commented 7 years ago

It looks like I don't have JSON::XS installed on this machine and

$ perl -MJSON::PP -wle 'print $JSON::PP::VERSION'
2.27400

Let me know if you need anything else.

mtve commented 7 years ago

some intermediate results: i believe it's a bug in AnyEvent::Handle/JSON::PP interrogation.

in line 1763 of AnyEvent::Handle $json->incr_skip; is not enough to reset broken state of json parser.

it only happens when the pool sends something strange, and it's not related to how many instances of script run simultaneously.

i guess i need to make a testcase and fill a bug to AnyEvent maintainer. and in the meanwhile figure out how to avoid triggering of this.

leto commented 7 years ago

I can tell you that this doesn't seem to ever happen when I only run 1 server.pl in a directory. But if I do cp server.pl server2.pl and you run both, logging to different log files, but both sharing lib/, this seems to happen after about a day, under light use. Perhaps this bug exists with only one server, but the race condition doesn't happen nearly often enough, not sure.

This is not blocking me currently, I am going to see if JSON::XS changes anything and I will add any more details that I find to this issue.

Also, latest AnyEvent is 7.14, maybe there is something related to this in recent version.

mtve commented 7 years ago

That's strange. It should not affect in this way.

Yep, checked 7.14, does not seem to fix this.

Well, I have my own event lib and json too, I just wanted to use standard modules. Can not promise dates, but will try to fix this asap.

If you want, please try to fix that line 1763 of AnyEvent::Handle like this: $json->incr_skip; $json->{incr_parsing} = 0;

mtve commented 7 years ago

it's opportunistic fix, hopeful workaround of this problem.

mtve commented 7 years ago

i close this issue, do not hesitate to open it again or open new ones for any problems.