Loading ...
Sorry, an error occurred while loading the content.

5148Re: SOAP::Lite interaction w/ Exception::Class results in Perl seg fault

Expand Messages
  • dtikhonov
    Jan 25, 2006
    • 0 Attachment
      Let's revisit this thread. I did my own investigation of the problem
      and realized that the problem is not stringification, but numeric
      conversion overloading done in Error.pm. Here's my analysis from

      I have a server written in Perl that does some tasks that clients ask
      it to. Requests and responses are passed using soap, namely
      SOAP::Lite. Responses can be successful or unsuccessful. The latter
      are of two types: error codes plus honest-to-God exceptions (well, as
      close as Perl comes to them, anyway) of type Error or
      Exception::Class. The problem occurs when SOAP::Serializer tries to
      serialize objects of type Error. Error.pm has the following code
      (shortened for our purposes):

      use overload ("0+" => 'value');
      sub value {
      my $self = shift;
      exists $self->{'-value'} ? $self->{'-value'} : undef;

      Note that this subroutine may return undef. Now, SOAP::Serializer
      calls subroutine gen_id on references, which for normal objects is
      just the value of memory address:

      sub gen_id { sprintf "%U", $_[1] }

      Now, the problem is that when objects of type Error do not have a
      value (returns undef), this produces a segfault in perl 5.6.1. This
      problem can be demonstrated with the following short script:

      package My;

      use overload ('0+' => 'num_conv');
      sub new {
      my $self = shift;
      bless {}, ref($self) || $self;
      sub num_conv { undef }

      package main;
      my $var = My->new;
      print int($var);

      We can see that gen_id should try to detect whether object has numeric
      conversion overloaded and if it does, use a different scheme to get
      the ID (such as Scalar::Util::refaddr, also suggested in the perlmonks


      - Dmitri.

      1. http://www.perlmonks.org/?node_id=525293
    • Show all 4 messages in this topic