Issue with AnyEvent::AIO
Dominik Csapak
d.csapak at proxmox.com
Mon Jul 3 08:47:09 CEST 2023
On 7/1/23 08:15, Marc Lehmann wrote:
> On Fri, Jun 30, 2023 at 08:31:14AM +0200, Dominik Csapak <d.csapak at proxmox.com> wrote:
>> Is there any way to detect that during runtime? (so i could go and try to
>> detect the parts of the code where that might happen.)
>
> You cna register apost_detect block and priont a stracktrace, e.g. something
> like this (untested):
>
> my $guard = AnyEvent::post_detect { use Carp; Carp::cluck "anyevent initialised" };
>
>> epoll_wait(4, [{events=EPOLLIN, data={u32=8, u64=4294967304}}], 64, 3346) = 1
>
> That basiclaly means that fd#8 is ready to read from, but nothiong reads
> from it. Maybe (on linux) looking at /proc/pid/fd can tell you what fd#8
> is? or maybe straceing the whole process can tell you what fd#8 is before
> it is added to the epoll set?
>
>> Is there any other information i can provide to help (some log output, strace, etc.?)
>> I would be very grateful if you could give any hint as to how i can
>
> Have you tried running your program with PERL_ANYEVENT_STRICT=1 in the
> environment? If the cause is a bug somewhjere, this will catch a lopt of
> common mistakes (but obviously won't catch everything).
>
> If that gives you an error something, that would also be worth investigating.
>
> It cannot catch fork-related issues.
>
Hi,
thanks for your tips and getting back to me.
In the end i found the root of our issue:
We had a 'use AnyEvent:IO' statement even though we did not use any of it.
This (with an installed libanyevent-aio-perl) seems to have triggered
the initialization of IO::AIO (which uses pthreads according to perldoc and is generally
not compatible with forking) and seems to have some effect on an epoll fd
in the END handler (we use some normal 'exit' calls in our code after forking)
AFAICS from testing changing from exit to POSIX::_exit also helps, as well as doing
'IO::AIO::reinit()' after the forking. Since we don't actually use it, we probably
just remove the use statement for now.
Thanks for all the help
Kind regards
Dominik
More information about the anyevent
mailing list