[Xml-compile] Crash on new

Gary Kennedy gary at apnic.net
Fri Dec 2 00:50:09 GMT 2011


I tracked it down to line 147 in Log::Report v0.94.

    if($stop)
    {   # ^S = EXCEPTIONS_BEING_CAUGHT, within eval or try
--->    $^S or exit($opts->{errno} || 0);
        $! = $opts->{errno} || 0;
        $@ = $exception || Log::Report::Exception->new(report_opts => $opts
          , reason => $reason, message => $message);
        die;   # $@->PROPAGATE() will be called, some eval will catch this
    }

And of course, creating a new ::WSDL11 object inside an import is happening at parsing time ($^S is undef). $stop, of course, is set if the exception is explicitly fatal, or the reason for the exception is fatal.

The line that is triggering the report is 196 in XML::Compile::Translate v1.22. (It's trying to compile the READER for xsd:schema)

    my $top  = $nss->find(element   => $fullname)
            || $nss->find(attribute => $fullname)
       or error __x(( $fullname eq $path
                    ? N__"cannot find element or attribute `{name}'"
                    : N__"cannot find element or attribute `{name}' at {where}"
                    ), name => $fullname, where => $path, _class => 'usage');

Where $fullname + $path are "{http://www.w3.org/2001/XMLSchema}schema";

The quickest fix I can think of is to remove the exit line from Log::Report since there is a die right after it anyways, but there's probably a use case I'm not aware of.

It seems to work ok on my test machine, but I haven't tested every case. And I'm not going to use this fix in production without confirmation :)

Cheers,
Gary


On 01/12/2011, at 6:10 PM, Mark Overmeer wrote:

> * Gary Kennedy (gary at apnic.net) [111201 04:19]:
>> To save execution time I'm compiling everything when the module gets
>> imported. (Yes, I now know about XML::Compiler::Dumper, but this is all
>> written and time critical so new modules later).
> 
> Please forget X::C::Dumper
> 
>> try {
>>     $wsdl = XML::Compile::WSDL11->new($wsdl_file, xsi_type => $typemap);
>>     $wsdl->importDefinitions($schema_file_list);
>> };
>> if ($@) { die 'error stuff' };
>> 
>> And when using this module in a script, it drops you back to the
>> command prompt after/during the ::WSDL11->new call.
> 
> You do no see the "error stuff" error?
> The "try{}" catches the error in $@.  So  "die $@" or remove the "try"
> block while debugging.
> 
>> Now, if I comment out the setup() call in the import block, and
>> manually run setup in the script, it all works fine.
> 
> Import is called during BEGIN, so when some of the components of
> your program may not have been loaded.  Better to use an explicit
> Interface->init() or something.
> -- 
> Regards,
> 
>               MarkOv
> 
> ------------------------------------------------------------------------
>       Mark Overmeer MSc                                MARKOV Solutions
>       Mark at Overmeer.net                          solutions at overmeer.net
> http://Mark.Overmeer.net                   http://solutions.overmeer.net
> 




More information about the Xml-compile mailing list