select() errors and AnyEvent::Loop

Felipe Gasper felipe at felipegasper.com
Wed Jun 30 21:51:25 CEST 2021



> On Jun 30, 2021, at 3:30 PM, Marc Lehmann <schmorp at schmorp.de> wrote:
> 
> On Wed, Jun 30, 2021 at 11:44:25AM -0400, Felipe Gasper <felipe at felipegasper.com> wrote:
>>> When I make EBADF happen directly the program hangs in a tight loop. I assume the same would go for ENOMEM, and EINVAL shouldn’t be possible in Perl.
>>> 
>>> How is it possible for a program that gets EBADF, EINVAL, or ENOMEM from select() to be correctly working?
> 
> I am not sure what your question even means - without knowing the
> specification of the program (which defines what correct means), we simply
> can't know, but an obvious answer would be: the specs call for the program
> to run into this condition and behave this way, puzzle solved.
> 
> What we do know is that, by all evidence, AnyEvent and AnyEvent::Loop
> behave correctly - obviously, neither module can make guarantees about
> user code, or fix it on the fly, or even attempt to guess what needs
> fixing (again, maybe this is correct behaviour for the program).
> 
> Now, we cna say one thing: barring bugs in AnyEvent, programs that
> get EBADF are not correct w.r.t. to AnyEvent's API, so if I had
> such a program, I would likely say it cannot work correctly, again
> .w.r.t. AnyEvent's API.
> 
> But AnyEvent is not a program, and who knows under what curious
> circumstances the whole program operates. I can easily imagine cases where
> the specification for such a program calls for this, while not affecting
> correctness negatively. AnyEvent, being free software you can modify and
> use for whatever purpose you see fit, is certainly fine with it, even if
> I, personally, wouldn't find this satisfactory.
> 
> AnyEvent::Loop does best effort in such cases, which is, however, not a
> guarantee made by AnyEvent::Loop, and certainly not by AnyEvent, which
> leaves such details to the loop.

Currently if that select() gets EBADF the program tight-loops indefinitely. Is there some circumstance where that’s somehow desirable? “Best effort” would, I’d think, be to throw in this case so that the problem is more easily identified.

We can certainly patch locally and likely will. It would just be nice for it to be upstream, too.

-F


More information about the anyevent mailing list