From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Tim Bunce <Tim(dot)Bunce(at)pobox(dot)com> |
Cc: | Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: plperl crash with Debian 6 (64 bit), pl/perlu, libwww and https |
Date: | 2011-08-07 23:39:11 |
Message-ID: | 4E3F221F.6000307@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 08/07/2011 07:06 PM, Tim Bunce wrote:
>
> After a little digging and some discussion on the #p5p channel [thanks
> to ilmari++ leont++ and sorear++ for their help] it seems that local(%SIG)
> doesn't do what you might expect. The %SIG does become empty but the OS
> level handlers, even those installed by perl, *aren't changed*:
>
> $ perl -wE '$SIG{INT} = sub { say "Foo"}; { local %SIG; kill "INT", $$; };'
> Foo
> And, even worse, they're not reset at scope exit:
>
> $ perl -wE '$SIG{INT} = sub { say "Foo"}; { local %SIG; $SIG{INT} = sub {say "Bar" }} kill "INT", $$;'
> Bar
>
> That sure seems like a bug (I'll check with the perl5-porters list).
Yeah, that seems very bad. :-(
> Localizing an individual element of %SIG works fine.
> In C that's something like this (untested):
>
> hv = gv_fetchpv("SIG", 0, SVt_PVHV);
> keysv = ...SV containing "ALRM"...
> he = hv_fetch_ent(hv, keysv, 0, 0);
> if (he) { /* arrange to restore existing elem */
> save_helem_flags(hv, keysv,&HeVAL(he), SAVEf_SETMAGIC);
> }
> else { /* arrange to delete a new elem */
> SAVEHDELETE(hv, keysv);
> }
>
>
Hmm. I think we'll need to test how much it's going to cost to add that
to every plperl (or maybe just every plperlu) function call for the six
or so signals we use.
cheers
andrew
From | Date | Subject | |
---|---|---|---|
Next Message | Tim | 2011-08-07 23:53:25 | Re: vacuumlo patch |
Previous Message | Tim Bunce | 2011-08-07 23:06:56 | Re: plperl crash with Debian 6 (64 bit), pl/perlu, libwww and https |