perl 5.18.1 + EV?

Darin McBride darin.mcbride at shaw.ca
Wed Oct 23 01:36:15 CEST 2013


On Tuesday October 22 2013 8:54:32 AM Marc Lehmann wrote:
> On Mon, Oct 21, 2013 at 05:56:56PM -0600, Darin McBride 
<darin.mcbride at shaw.ca> wrote:
> > Yes.  I have an object hierarchy going: Moose -> X -> Y -> Z.  If I do
> > that, it works, but if I remove "Y" from the list, then it dies.  I'm
> > going to continue looking at that to see if I can pare it down to not
> > using any of my hierarchy and just something you can use/see.
> 
> Interesting (smells like stack corruption on extend or so somewhere).

When I go in via gdb at the point of segfault, I get the segfault in 
Perl_pad_push here:

	PAD** const svp = PadlistARRAY(padlist);
	AV* const newpad = newAV();
	SV** const oldpad = AvARRAY(svp[depth-1]);

Turns out that svp[depth-1] is NULL.  Perhaps the extra package in the 
hierarchy means that we're one level deeper and so it's not NULL?

> > > A testcase would be the next step :)
> > 
> > Here's one:
> > 
> > $ dev_perl -MCoro -MAnyEvent::DBI -de 1
> 
> Unfortunately, this works just fine here :/

What does that load for you?  I get:

perl -MCoro -MAnyEvent::DBI -E 'say for sort keys %INC'
AnyEvent.pm
AnyEvent/DBI.pm
AnyEvent/Util.pm
AnyEvent/constants.pl
Carp.pm
Config.pm
Coro.pm
Coro/State.pm
Coro/jit-amd64-unix.pl
DBI.pm
DynaLoader.pm
Errno.pm
Exporter.pm
Exporter/Heavy.pm
Fcntl.pm
Guard.pm
List/Util.pm
POSIX.pm
Scalar/Util.pm
Socket.pm
Storable.pm
Tie/Hash.pm
XSLoader.pm
base.pm
common/sense.pm
feature.pm
strict.pm
vars.pm
warnings.pm
warnings/register.pm

I'm not sure if we have any difference on this...

> > Note that when I try to debug my real code, I get the panic elsewhere, but
> 
> > still somewhere in Coro:
> I would guesss the panic is likely not due to the code being executed when
> it panics, but due to some code executed much earlier, so you see it in
> more or less random places.

Agreed.  The fun of C programming where you're managing your own memory, 
pointer arithmetic, etc., especially in any code that is non-trivial.

> > Note that if I remove -MCoro, then the above debugger works fine.  Also,
> > if I add in -MAnyEvent::Loop it also works fine.  Hmm - I should try that
> > with my real code - remove EV, switch to AnyEvent::Loop...
> 
> Have you tried valgrind? It doesn't work that well with perl, but it sitll
> has a small chance of detecting e.g. freed memory reusage, which *might*
> be the reason here (but likely isn't).

I hadn't, but I've tried it now.  And, yes, there is some sort of leak going 
on:

==19433== LEAK SUMMARY:
==19433==    definitely lost: 52 bytes in 1 blocks
==19433==    indirectly lost: 192 bytes in 8 blocks
==19433==      possibly lost: 33,265,541 bytes in 46,871 blocks
==19433==    still reachable: 22,143,183 bytes in 150,035 blocks
==19433==         suppressed: 0 bytes in 0 blocks
==19433== Reachable blocks (those to which a pointer was found) are not shown.

But, when I run one that does NOT crash, I get:

==26807== LEAK SUMMARY:
==26807==    definitely lost: 2,937,080 bytes in 4,048 blocks
==26807==    indirectly lost: 29,882,780 bytes in 42,695 blocks
==26807==      possibly lost: 189,374 bytes in 298 blocks
==26807==    still reachable: 68,484 bytes in 179 blocks
==26807==         suppressed: 0 bytes in 0 blocks
==26807== Reachable blocks (those to which a pointer was found) are not shown.
==26807== To see them, rerun with: --leak-check=full --show-reachable=yes

So, I'm not sure how useful that is :)  (But if I eliminate AnyEvent::DBI, 
Coro, etc., and do nothing, there's nothing lost, so I can't be sure this is 
perl vs AE/Coro.)

I'm not sure if they're of any value here, but they're attached in case they 
are.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: valgrind.out.crash.gz
Type: application/x-gzip
Size: 37510 bytes
Desc: not available
URL: <http://lists.schmorp.de/pipermail/anyevent/attachments/20131022/03507039/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: valgrind.out.good.gz
Type: application/x-gzip
Size: 33894 bytes
Desc: not available
URL: <http://lists.schmorp.de/pipermail/anyevent/attachments/20131022/03507039/attachment-0003.bin>


More information about the anyevent mailing list