Re: plperl crash with Debian 6 (64 bit), pl/perlu, libwww and https - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: plperl crash with Debian 6 (64 bit), pl/perlu, libwww and https
Date
Msg-id 4E3F221F.6000307@dunslane.net
Whole thread Raw
In response to Re: plperl crash with Debian 6 (64 bit), pl/perlu, libwww and https  (Tim Bunce <Tim.Bunce@pobox.com>)
List 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


pgsql-hackers by date:

Previous
From: Tim Bunce
Date:
Subject: Re: plperl crash with Debian 6 (64 bit), pl/perlu, libwww and https
Next
From: Tim
Date:
Subject: Re: vacuumlo patch