mojolicious / mojo

:sparkles: Mojolicious - Perl real-time web framework
https://mojolicious.org
Artistic License 2.0
2.66k stars 577 forks source link

Use of uninitialized value $cb in method lookup at Mojo/Reactor/Poll.pm #2128

Open e477 opened 10 months ago

e477 commented 10 months ago

We use the Mojo::UserAgent for our data scraper and we get lots of errors like this:

Use of uninitialized value $cb in method lookup at /usr/local/lib/perl5/Mojo/Reactor/Poll.pm line 141.
eval {...} called at /usr/local/lib/perl5/Mojo/Reactor/Poll.pm line 141
Mojo::Reactor::Poll::_try(Mojo::Reactor::EV=HASH(0x564e73e33fd8), "I/O watcher", undef, 0)
    called at /usr/local/lib/perl5/Mojo/Reactor/EV.pm line 54

Looking at the code, the docs and similar bug reports this seems to be the result of EV::io emitting two or more events in succession with the earlier event removing the handler while the callback for a later event is still pending.

Mojo/Reactor/EV.pm will catch this situation, but only for write events (line 55). For read events the check for existance of the handler is missing (line 54).

Steps to reproduce the behavior

I've yet been unable to reproduce this error in a test case.

Expected behavior

No errors.

Actual behavior

See above.

kraih commented 10 months ago

Suppose a shared check for the data structure would make sense. This has to be incredibly rare though.