develooper Front page | perl.perl5.porters | Postings from April 2018

[perl #133142] Bleadperl breaks Devel::FindRef

Thread Previous
bulk88 via RT
April 26, 2018 09:18
[perl #133142] Bleadperl breaks Devel::FindRef
Message ID:
On Wed, 25 Apr 2018 03:56:42 -0700, davem wrote:
> On Mon, Apr 23, 2018 at 04:52:26AM -0700, Sergey Aleynikov wrote:
> > commit eacbb37937698a035d5ed63fcbdf15dd4eab56cf
> > Author: Daniel Dragan <>
> > Date:   Fri Oct 31 03:23:17 2014 -0400
> > 
> >     free up CvPADLIST slot for XSUBs for future use
> > 
> > broke Devel::FindRef for perls compiled with -DDEBUGGING with the
> > following assertion failure:
> > 
> > perl: FindRef.xs:180: XS_Devel__FindRef_find_: Assertion
> > `!(((XPVCV*)({ void *_p = (((CV*)(sv))->sv_any); _p; }))->xcv_flags &
> > 0x0008)' failed.
> > 
> > While a patch for Devel::FindRef is quite trivial, I'd like to know,
> > are there any plans for CvPADLIST slots in XSUBs? Or isn't this
> > assertion obsolete now?
> I think Daniel would have to be the one to answer that question,
> but in general, freeing up a slot in CV for potential future new uses 
> seems like a Good Thing, and so the assertion isn't obsolete.
> (Since this change was in 5.22.0, I'm removing this ticket from the 5.28
> blockers list.)

The assertion stops XS code from reading the "padlist" of an XSUB. There is no legitimate reason to read the "padlist" of an XSUB since XSUBs dont have any and the proc will probably SEGV. The padlist slot in XSUBs is used on unthreaded perl to pass a magic unique value that must round trip from the caller (IE libperl) of the XSUB, through the XSUB and back into libperl. This stops a scenario where an XS SO/DLL compiled against another perl version, is loaded by one perl (a PATH/CWD/PERL5DB/PERL5LIB/sitecustomize/@INC/didnt delete "site/lib/auto" dir when upgrading perl/copy paste XS binaries mistake), and that XS SO/DLL then loads its original compiled against libperl into the process, and takes data structs from the caller libperl and passes them to the second libperl and there is a SEGV inside the 2nd libperl.

Fixing Devel::FindRef is very easy. I did see the assert failure. But it was easy to fix.

                          case SVt_PVCV:
                              if(!CvISXSUB(sv)){<<<<<<<<<<<ADDD THIS
                              PADLIST *padlist = CvPADLIST (sv);

                              if (padlist)

and add a matching "}" after the end of "if (padlist)"'s "}".

This is more crude but also works.

                          case SVt_PVCV:
                              PADLIST *padlist = CvISXSUB(sv) ? NULL : CvPADLIST (sv);

                              if (padlist)

bulk88 ~ bulk88 at

via perlbug:  queue: perl5 status: open

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About