Mailing List Archive

PERL_SIGNALS=unsafe
I'm in a situation where a bit of code in a usertag that I have which
uses an alarm does not work properly with PERL_SIGNALS=unsafe (it works
fine with PERL_SIGNALS=safe). As a result I'm trying to understand what
the reasoning is for the PERL_SIGNALS=unsafe recommendation in Interchange?

Just FYI the code that I'm having issues with is the following:

my $try = 0;
{
eval {
# Use an alarm to trigger the timeout
local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
alarm 5;

# Do something here that sometimes locks up and needs to timeout

alarm 0;
};
if ($@) {
if ($try++ < 10 && $@ =~ /alarm/) {
redo;
}
::logError($@);
return;
}
}

In the above code block, with PERL_SIGNALS=unsafe, if the timeout
condition occurs the first time then the alarm is properly triggered and
the code loops around and tries again, but the second time the alarm
doesn't trigger and so the block locks up until it times out via some
other mechanism.

As I said above, it works fine with PERL_SIGNALS=safe.


Peter

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users
Re: PERL_SIGNALS=unsafe [ In reply to ]
Quoting Peter (peter@pajamian.dhs.org):
> I'm in a situation where a bit of code in a usertag that I have which
> uses an alarm does not work properly with PERL_SIGNALS=unsafe (it works
> fine with PERL_SIGNALS=safe). As a result I'm trying to understand what
> the reasoning is for the PERL_SIGNALS=unsafe recommendation in Interchange?

It had to do with the incidence rate of the blue moon interrupt signal crash in
Perl. When you ran with "safe" signals it would occur much more frequently.

This may not at all apply in later Perls, so I would take the recommendation
with a grain of salt for anything beyond 5.10.

>
> Just FYI the code that I'm having issues with is the following:
>
> my $try = 0;
> {
> eval {
> # Use an alarm to trigger the timeout
> local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
> alarm 5;
>
> # Do something here that sometimes locks up and needs to timeout
>
> alarm 0;
> };
> if ($@) {
> if ($try++ < 10 && $@ =~ /alarm/) {
> redo;
> }
> ::logError($@);
> return;
> }
> }
>
> In the above code block, with PERL_SIGNALS=unsafe, if the timeout
> condition occurs the first time then the alarm is properly triggered and
> the code loops around and tries again, but the second time the alarm
> doesn't trigger and so the block locks up until it times out via some
> other mechanism.
>
> As I said above, it works fine with PERL_SIGNALS=safe.
>
>
> Peter
>
> _______________________________________________
> interchange-users mailing list
> interchange-users@icdevgroup.org
> http://www.icdevgroup.org/mailman/listinfo/interchange-users

--
Mike Heins
End Point -- Expert Internet Consulting http://www.endpoint.com/
phone +1.765.253.4194 <mikeh@endpoint.com>

Any man who is under 30, and is not liberal, has not heart; and any man
who is over 30, and is not a conservative, has not brains.
-- unknown, often falsely attributed to Winston Churchill

_______________________________________________
interchange-users mailing list
interchange-users@icdevgroup.org
http://www.icdevgroup.org/mailman/listinfo/interchange-users