develooper Front page | perl.perl5.porters | Postings from June 2015

Re: 5.22 breaks Coro-6.42

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
June 24, 2015 11:59
Subject:
Re: 5.22 breaks Coro-6.42
Message ID:
20150624115900.GI15986@iabyn.com
On Mon, Jun 08, 2015 at 08:46:34PM +0200, Max Maischein wrote:
> Hello Daniel,
> 
> thank you for the description which I think should enable me to make the
> changes to Coro.
> 
> Am 31.05.2015 um 22:13 schrieb bulk88:
> >Max Maischein wrote:
> >>I did some spelunking in git history and some comparing between 5.20
> >>and 5.22-RC2, and here are my findings (as on irc):
> >>
> >>There are two errors. One can be easily fixed by reverting the patch
> >>c910fead7893fe9700031ee59de6b904260b5d69 :
> >>
> >>State.xs:3472:9: error: assignment of member 'svt_get' in read-only
> >>object
> >>         orig_sigelem_get = PL_vtbl_sigelem.svt_get;
> >>PL_vtbl_sigelem.svt_get
> >> = coro_sigelem_get;
> >>         ^
> >> [...]
> >
> >Since I wrote that patch the solution is make your own magic vtable
> >(struct mgvtbl), copy the function pointers you want from the core's
> >vtable RO vtable to your RW vtable in your XS module. Then call
> >mg_findext to get the core created MG *, and assign your vtable to
> >mg->mg_virtual replacing the core one.
> 
> I think this approach is problematic since it will only replace the existing
> magic for elements in %SIG that exist at patching time. Elements added to
> %SIG after Coro has loaded will get the original Perl sigelem magic and not
> the changed magic, at least that is how I interpret the C code and data. As
> the main purpose of this vtable switching is to provide custom setters and
> getters for $SIG{__DIE__} and $SIG{__WARN__}, I think there needs to be more
> magic added to %SIG such that it attaches the correct kind of magic to
> elements stored in
> it.
> 
> Is the above interpretation correct or am I overlooking something?


That sounds about right.

You have to construct a new vtable for %SIG, then set mg_virtual on %SIG
to point to it (it's currently null), and set the MGf_COPY flag.  In the
vtable, add a svt_copy method, which will be responsible for attaching
magic to new $SIG elements. (see Perl_mg_copy). If the element is __WARN__
or __DIE__, make the element point to a new vtable.

Also at BOOT: time, check %SIG for existing __WARN__ and __DIE__ entries,
and if they exist, change their mg_virtual pointer.

-- 
Never do today what you can put off till tomorrow.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About