http://qs1969.pair.com?node_id=11145983


in reply to Re: XS Error: Segfault with B::HooksAtRuntime
in thread XS Error: Segfault with B::HooksAtRuntime

I can't solve the problem, but that info turned out to be sufficient for me to guess where to poke. I can reproduce a segfault in just 7 lines of code.

File: mx_segfault.pl
use lib '.'; use Demo;
File: Demo.pm
package Demo; use MooseX::Extended; require Stuff;
File: Stuff.pm
package Stuff; use MooseX::Extended;
With this code, perl -wc mx_segfault.pl segfaults, and valgrind throws a 455-line tantrum.

Replies are listed 'Best First'.
Re^3: XS Error: Segfault with B::HooksAtRuntime
by dave_the_m (Monsignor) on Aug 06, 2022 at 18:31 UTC
    In general terms, that valgrind output shows that the calling of a sub while running code via call_after() (which requires a new CXt_SUB context sub to be pushed) grows the context stack (by reallocating it). Sometime later when exiting a use/require, the Cxt_EVAL frame is accessed using the old context stack address (the smaller stack that was freed when a larger one was allocated). So maybe something is holding on to a context stack pointer when it shouldn't - either in core or XS.

    Dave.

Re^3: XS Error: Segfault with B::HooksAtRuntime
by Ovid (Cardinal) on Aug 06, 2022 at 16:44 UTC