SPUG: object refs in Perl 5.6.1 vs 5.8.4

dleonard at dleonard.net dleonard at dleonard.net
Fri May 26 15:52:38 PDT 2006


Based on past experience with similar issues I would guess that an AUTOLOAD somewhere is biting you.  In fact at our previous employer's long, long ago I believe I ran into the exact same issue.  Something in startup.pl was loading a module with an AUTOLOAD that was hosing up everything downstream.

-- 

<Douglas Leonard>
<dleonard at dleonard.net>

On Fri, 12 May 2006, Andrew Sweger wrote:

> I feel like I'm going nuts. Please show me how nuts I am. I have some code
> that runs fine in development and promptly goes whacky in production.
> First, the environments:
>
>     Dev
>     ---
>     Debian 3.1 (sarge)
>       w/ Linux 2.4.27
>     Perl 5.8.4
>     Apache 1.3.33
>     mod_perl 1.29.0.3 (via libapache-mod-perl)
>
>     Production
>     ----------
>     Red Hat Enterprise Linux ES release 2.1 (Panama) (no choice)
>       w/ linux 2.3.9-e.65smp (no choice)
>     Perl 5.6.1 (no choice)
>     Apache 1.3.27-10.ent (no choice)
>     mod_perl 1.26-2 (no choice)
>
> I cannot duplicate the production environment in development. Nor would I
> do so except under threat of violent torture.
>
> My code is a CGI::Application using HTML::Template. The problem only
> appears when running under Apache/mod_perl(Apache::Registry) in
> production. I do clean restarts of the Apache server after making each
> code change (and sometimes complete stop/start cycles). The problem does
> not appear when running the code from the cammand line. It all runs fine
> in the dev environment.
>
> It seems that object methods that are supposed to return objects from
> another class (or just a simple hash ref) are suddenly just returning a
> scalar string containing the name of the thing I was trying to get back.
>
> Does that ring any bells yet?
>
> For example, in my application's cgiapp_postrun callback (automatically
> hooked by CGI::Application), I ask for $self->session() expecting a
> hash-ref or undef, I get back q{session}. I ask for
> $self->param('affiliate') expecting a My::Affiliate blessed object or
> undef), I get back q{affiliate}. These later blow up when I attempt to
> call further methods or de-refs on (for example) $sess->{'status'} which
> dies complaining I tried to use a string as a hash ref while under the
> influence of "strict refs" (strict is on *everywhere* in my code, except
> where it specifically is not, and this ain't one of 'em).
>
>     my $sess = $self->session();
>     my $affiliate = $self->param('affiliate');
>
> I'm dying for someone to say, "Ah, Andrew. You simpleton. Have you already
> forgotten ___________________?"
>
> Somebody at least say, "Wow, dude. That sure is weird." I'd almost swear
> there's nothing in the code path that could be returning those dumb
> strings.
>
> --
> Andrew B. Sweger -- The great thing about multitasking is that several
>                                 things can go wrong at once.
>
>
> _____________________________________________________________
> Seattle Perl Users Group Mailing List
>      POST TO: spug-list at pm.org
> SUBSCRIPTION: http://mail.pm.org/mailman/listinfo/spug-list
>     MEETINGS: 3rd Tuesdays
>     WEB PAGE: http://seattleperl.org/
>



More information about the spug-list mailing list