Grokbase
x

David Golden (dag...@cpan.org)

Profile | Posts (1)

User Information

Display Name:David Golden
Partial Email Address:dag...@cpan.org
Posts:
1 total
1 in Perl 5 Porters

5 Most Recent

1) David Golden Re: [perl #70487] Perl interpreter exits when calling print on a closed socket
| +1 vote
Of course!. That could probably be better documented. Not being an IPC expert, I wouldn't have...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Sat, Nov 14, 2009 at 1:25 PM, Eric Brine <ikegami@adaelis.com> wrote:
> Which is SIGPIPE with a core dump. SIGPIPE is thrown by the system when
> writing to a closed pipe or socket.It can be caught or ignored using
>
> =C2=A0 =C2=A0$SIG{PIPE} =3D 'IGNORE';
>
> Not a bug (in Perl).

Of course!.  That could probably be better documented.  Not being an
IPC expert, I wouldn't have expected it except for actual pipes.
Grepping for SIGPIPE in blead's pod/ directory did reveal this in
perl581delta:

> If a socket gets closed by the server while printing to it, the client
> now gets a SIGPIPE. While this new feature was not planned, it fell
> naturally out of PerlIO changes, and is to be considered an accidental
>  feature.

But almost all the other references are in relation to pipes, not
filehandles or sockets.

Maybe it could be added at least to Socket.pm or perlfunc for
'socket'.  perlfunc for 'print' would be another good place to note
that printing to a closed socket or pipe will throw SIGPIPE.

-- David
2) David Golden [PATCH] Have Carp respect CORE::GLOBAL::caller if it exists
| +1 vote
Carp frequently gets loaded very early, before tools that want to override caller(). Previously,...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
Carp frequently gets loaded very early, before tools that want to
override caller().  Previously, caller() was only in Carp::Heavy,
which was only loaded on demand (thus after any CORE::GLOBAL::caller
override).  This patch unbreaks anything expecting the old behavior.
---
 lib/Carp.pm |   15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/lib/Carp.pm b/lib/Carp.pm
index 69d5c1f..0826016 100644
--- a/lib/Carp.pm
+++ b/lib/Carp.pm
@@ -43,7 +43,7 @@ sub longmess {
     # number of call levels to go back, so calls to longmess were off
     # by one.  Other code began calling longmess and expecting this
     # behaviour, so the replacement has to emulate that behaviour.
-    my $call_pack = caller();
+ my $call_pack = exists $CORE::GLOBAL::{caller} ? $CORE::GLOBAL::{caller}->() : caller();
     if ($Internal{$call_pack} or $CarpInternal{$call_pack}) {
       return longmess_heavy(@_);
     }
@@ -55,7 +55,7 @@ sub longmess {

sub shortmess {
     # Icky backwards compatibility wrapper. :-(
-    local @CARP_NOT = caller();
+ local @CARP_NOT = exists $CORE::GLOBAL::{caller} ? $CORE::GLOBAL::{caller}->() : caller();
     shortmess_heavy(@_);
};

@@ -70,7 +70,7 @@ sub caller_info {
   my %call_info;
   @call_info{
     qw(pack file line sub has_args wantarray evaltext is_require)
-  } = caller($i);
+ } = exists $CORE::GLOBAL::{caller} ? $CORE::GLOBAL::{caller}->($i) : caller($i);
   
   unless (defined $call_info{pack}) {
     return ();
@@ -149,7 +149,8 @@ sub long_error_loc {
   my $i;
   my $lvl = $CarpLevel;
   {
-    my $pkg = caller(++$i);
+    ++$i;
+ my $pkg = exists $CORE::GLOBAL::{caller} ? $CORE::GLOBAL::{caller}->($i) : caller($i);
     unless(defined($pkg)) {
       # This *shouldn't* happen.
       if (%Internal) {
@@ -224,8 +225,10 @@ sub short_error_loc {
   my $i = 1;
   my $lvl = $CarpLevel;
   {
-    my $called = caller($i++);
-    my $caller = caller($i);
+
+ my $called = exists $CORE::GLOBAL::{caller} ? $CORE::GLOBAL::{caller}->($i) : caller($i);
+    $i++;
+ my $caller = exists $CORE::GLOBAL::{caller} ? $CORE::GLOBAL::{caller}->($i) : caller($i);

     return 0 unless defined($caller); # What happened?
     redo if $Internal{$caller};
--
1.6.0.4
3) David Golden Re: [perl #70043] Re: [Sysadmins] Perl allows non-sensical operations on reference converted to an integer
| +1 vote
Module loading in general. Otherwise, 'use Scalar::Util qw/refaddr/'. The question is whether...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Tue, Oct 27, 2009 at 7:35 AM, Nicholas Clark <nick@ccl4.org> wrote:
> On Tue, Oct 27, 2009 at 07:27:01AM -0400, David Golden wrote:
>
>> I might be in favor of refaddr() moving into core from Scalar::Util so
>> it's always available even if module loading is borked.
>
> If "your" module loading is borked, we don't support "you".

Module loading in general.  Otherwise, 'use Scalar::Util qw/refaddr/'.
The question is whether refaddr is something that really *must* be
there when @INC is wrong/empty or the dirs are missing/renamed.  Seems
a bit esoteric to me, but if someone insists that something replace
reference stringification...

-- David
4) David Golden Re: [perl #70043] Re: [Sysadmins] Perl allows non-sensical operations on reference converted to an integer
| +1 vote
Fortunately, you'd still be able to do so in pre-5.10 perl. :-) Making reference stringification a...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Tue, Oct 27, 2009 at 7:21 AM, Abigail <abigail@abigail.be> wrote:
> I use often stringified references. Either by printing them (debugging
> tool), or as hash keys. If I want a quick and dirty implementation
> of inside out objects and I'm using a pre-5.10 perl, I use objects
> as keys keys directly.
>
> Forbidding anything that may lead to an error somewhere else in the
> code would quickly leave us with no construct in the language at all.

Fortunately, you'd still be able to do so in pre-5.10 perl.  :-)

Making reference stringification a warning wouldn't stop quick and
dirty debugging, which is why I say that would, at a minimum, be an
improvement on the current situation.

I might be in favor of refaddr() moving into core from Scalar::Util so
it's always available even if module loading is borked.

-- David
5) David Golden Re: [perl #70043] Re: [Sysadmins] Perl allows non-sensical operations on reference converted to an integer
| +1 vote
That "idiom" is an accident waiting to happen because of overloading. It should at least warn. But...
Perl 5 Porters
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
On Tue, Oct 27, 2009 at 7:05 AM, Nicholas Clark <nick@ccl4.org> wrote:
> On Tue, Oct 27, 2009 at 07:00:07AM -0400, David Golden wrote:
>> To me, it seems consistent with the idea "use strict 'refs'" -- if
>> strictures are on, stringifying or numifying a reference should be a
>> fatal error. =C2=A0If someone needs it, they should use refaddr anyway
>> because of overloading. =C2=A0So to clarify, it should be fatal *unless*
>> it's a blessed object with numification or stringification
>> overloading.
>
> Which breaks existing code that uses strict, and the idiom of using the
> stringification of references as hash keys.

That "idiom" is an accident waiting to happen because of overloading.
It should at least warn.  But I actually think it should be fatal
under strictures -- that's the whole point of strictures.  You can
turn them off and be unsafe, but you need to know what you're doing.
Now that Scalar::Util is core, refaddr() is available and should
always be used to get a reference address.  (refaddr should *not*
warn/die, because it's explicit.)

-- David

spacer
Profile | Posts (1)
Home > People > David Golden