CC: | geraud [...] gcu.info, kuriyama [...] FreeBSD.org |
Subject: | IO::KQueue pushes C NULLs into an AV, which it should not |
Hi,
Geraud CONTINSOUZAS has recently reported assertion failures related to
IO::KQueue on FreeBSD with perl 5.10.1 compiled with -DDEBUGGING.
The culprit turned out to be C NULLs pushed into Perl AV when udata is
not specified.
While in previous versions of perl, as well as with perl compiled
without debugging (and without extra assertions) it silently worked,
it certainly does not look like a good practice.
The attached patch fixes the problem.
I hope you'll release an updated version soon.
Thanks,
\Anton.
Subject: | kqueue.patch |
--- KQueue.xs.orig 2009-09-29 10:42:31.000000000 +0200
+++ KQueue.xs 2009-09-29 10:44:43.000000000 +0200
@@ -107,7 +107,8 @@ kevent(kq, timeout=&PL_sv_undef)
av_push(array, newSViv(ke[i].flags));
av_push(array, newSViv(ke[i].fflags));
av_push(array, newSViv(ke[i].data));
- av_push(array, SvREFCNT_inc(ke[i].udata));
+ if (ke[i].udata)
+ av_push(array, SvREFCNT_inc(ke[i].udata));
PUSHs(sv_2mortal(newRV_noinc((SV*)array)));
}
@@ -152,7 +153,10 @@ get_kev(kq, i)
sv_setiv(AvARRAY(ke2av)[2], ke2[i-1].flags);
sv_setiv(AvARRAY(ke2av)[3], ke2[i-1].fflags);
sv_setiv(AvARRAY(ke2av)[4], ke2[i-1].data);
- av_store(ke2av, 5, SvREFCNT_inc(ke2[i-1].udata));
+ if (ke2[i-1].udata)
+ av_store(ke2av, 5, SvREFCNT_inc(ke2[i-1].udata));
+ else
+ av_store(ke2av, 5, &PL_sv_undef);
RETVAL = newRV_inc((SV*) ke2av);