You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Stefano <st...@antartide.org> on 2002/08/29 17:21:12 UTC

base.pm seems to fail a check

Hello,

I was not able to find anything similar in list archives,

Trying to :

	use base Ima::DBI

in mod_perl (also in a <Perl></Perl> block of config)
a cought this trace:

 Uncaught exception from user code:
	Can't locate DBI/db.pm in @INC (@INC contains: [...]


This happens because Ima::DBI 'uses' base DBI::db at line 645 of his
source code and DBI::db is not a package available from @INC but
directly from the DBI namespace.


In these cases base.pm (line 42) steps into an unless{} block
to by-pass 'Can't locate ...' exceptions rised from inside base.pm
itself:

	eval "require $base";
        # Only ignore "Can't locate" errors from our eval require.
        # Other fatal errors (syntax etc) must be reported.
------> die if $@ && $@ !~ /^Can't locate .*? at \(eval /; #'# <------


Working outside mod_perl (i.e. in a command line perl program) no
problem jumps out because the above arrowed 'die' correctly matches
its regexp (the exception message starts at the beginning of the line).

>From inside mod_perl we have an unmatch so base croaks with the complete
backtrace and httpd doesn't start (if I pre-use the module) or send
500 - Server Error (in a runtime require).

With the follow substitution it works, but I'm sure there is a better
and more correct way to behave with.

    In base.pm :
    
    42: <<< die if $@ && $@ !~ /^Can't locate .*? at \(eval /; #'#
    42: >>> die if $@ && $@ !~ /Can't locate .*? at \(eval /; #'#


Any suggests?


Thanks a lot,
Stefano di Sandro

Re: base.pm seems to fail a check

Posted by Stefano <st...@antartide.org>.
On Fri, 30 Aug 2002 10:44:46 +0800
Stas Bekman <st...@stason.org> wrote:

Hello Stas,
nice to meet you.

> 
> I can think of 2 things:
> 
> 1. override the problematic subroutine in base.pm so it'll do the
> right thing.

This works.
Anyway the problem is that mod_perl prints out the trace prepending the
string:

"Uncaught exeption from user code:\n\s\s\s"

to the perl error one:

"Can't locate DBI/db.pm in @INC ..."

then base.pm fails its re.

So these 2 are in mutex:

 1. I'm not able to use mod_perl and I need help in stuff like error
    handling
 2. base.pm is bugged (or mod_perl is not compliant) and no one in the
    whole world has been able to "use Ima::DBI" in mod_perl, ever.

I'm sure the second has value 'false'.
	


> 
> 2. preload the module that you pass to 'use base' before loading the 
> module that includes 'use base ...'
This didn't work. Same error.

Thanks,
Stefano

Re: base.pm seems to fail a check

Posted by Stas Bekman <st...@stason.org>.
Stefano wrote:
> Hello,
> 
> I was not able to find anything similar in list archives,
> 
> Trying to :
> 
> 	use base Ima::DBI
> 
> in mod_perl (also in a <Perl></Perl> block of config)
> a cought this trace:
> 
>  Uncaught exception from user code:
> 	Can't locate DBI/db.pm in @INC (@INC contains: [...]
> 
> 
> This happens because Ima::DBI 'uses' base DBI::db at line 645 of his
> source code and DBI::db is not a package available from @INC but
> directly from the DBI namespace.
> 
> 
> In these cases base.pm (line 42) steps into an unless{} block
> to by-pass 'Can't locate ...' exceptions rised from inside base.pm
> itself:
> 
> 	eval "require $base";
>         # Only ignore "Can't locate" errors from our eval require.
>         # Other fatal errors (syntax etc) must be reported.
> ------> die if $@ && $@ !~ /^Can't locate .*? at \(eval /; #'# <------
> 
> 
> Working outside mod_perl (i.e. in a command line perl program) no
> problem jumps out because the above arrowed 'die' correctly matches
> its regexp (the exception message starts at the beginning of the line).
> 
>>>From inside mod_perl we have an unmatch so base croaks with the complete
> backtrace and httpd doesn't start (if I pre-use the module) or send
> 500 - Server Error (in a runtime require).
> 
> With the follow substitution it works, but I'm sure there is a better
> and more correct way to behave with.
> 
>     In base.pm :
>     
>     42: <<< die if $@ && $@ !~ /^Can't locate .*? at \(eval /; #'#
>     42: >>> die if $@ && $@ !~ /Can't locate .*? at \(eval /; #'#

Obviously, base.pm should flex it's regex, but this is not an option 
with released perls.

I can think of 2 things:

1. override the problematic subroutine in base.pm so it'll do the right 
thing.

2. preload the module that you pass to 'use base' before loading the 
module that includes 'use base ...'

in any case, please check whether the problem persists in the bleed-perl 
(i.e. 5.9.0-dev) and if so, make sure it gets fixed, by sending a 
bugreport to p5p.


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


RE: base.pm seems to fail a check

Posted by Jesse Erlbaum <je...@erlbaum.net>.
Hi Stefano --

> Working outside mod_perl (i.e. in a command line perl program) no
> problem jumps out because the above arrowed 'die' correctly matches
> its regexp (the exception message starts at the beginning of the line).
>
> From inside mod_perl we have an unmatch so base croaks with the complete
> backtrace and httpd doesn't start (if I pre-use the module) or send
> 500 - Server Error (in a runtime require).


I find that a problem which occurs INSIDE Apache/mod_perl but does not occur
OUTSIDE from the command line is usually attributable to one or both of the
following:

  1. Perl version mis-match between installed Perl and version compiled into
Apache.
  2. Web server permissions issue.

If I were you I would closely compare the different versions and settings of
the installed perl and the compiled apache/perl.


TTYL,

-Jesse-


--

  Jesse Erlbaum
  The Erlbaum Group
  jesse@erlbaum.net
  Phone: 212-684-6161
  Fax: 212-684-6226