Can't return outside a subroutine, <SOCKET> line 138.

[prev] [thread] [next] [Date index for 2005/03/15]

From: jet
Subject: Can't return outside a subroutine, <SOCKET> line 138.
Date: 22:26 on 15 Mar 2005
i'm losing my mind here;

to protect the client, i am 're-naming' the module names for 
confidentiality, but I have a seriously weird problem that is not adding up 
to anything intuitive for me at all.

We have a foundation module that deals with interacting with our 
databases... higher level modules then base themselves off this foundation,. 
which provides functionalities such 
as ->select, ->new, ->save, ->update, ->find ...

well, we've recently upgraded servers and moved towards apache2/modperl2

more precisely:

httpd-2.0.52-9.ent
mod_perl-1.99_16-4
perl-5.8.5-12.1

anyhow, forgive the mess, but here is a clip from the offending subroutine:

---------------
    $sql .= " ($args{FIELD} NOT IN $args{NOTIN}) " if $args{NOTIN};

     warn " <- line 903: $sql\n";

        $sql =~ s/\sAND$//; warn " <- line 905: $sql\n";
        $sql .= " GROUP BY $args{GROUPBY}" if $args{GROUPBY}; warn " <- line 
906: $sql\n";
        $sql .= " HAVING $args{HAVING}" if $args{HAVING}; warn " <- line 
907: $sql\n";
        $sql .= " ORDER BY $args{ORDERBY}" if $args{ORDERBY}; warn " <- line 
908: $sql\n";

 warn " <- line 910: $sql\n";
    $sql .= ' LIMIT 1' unless $wantarray;

    warn "ModuleName::build_sql -> \$sql = $sql\n";

    return $sql;
}

-----------------

in our error log we get:

------------------

 <- line 895: SELECT ID FROM ultsys.rules WHERE ( hasvalue IN (392)
       AND field LIKE 'quotaleft'
       AND actionID = 1636
       AND criteria > 0) AND
 <- line 899: SELECT ID FROM ultsys.rules WHERE ( hasvalue IN (392)
       AND field LIKE 'quotaleft'
       AND actionID = 1636
       AND criteria > 0) AND
 <- line 903: SELECT ID FROM ultsys.rules WHERE ( hasvalue IN (392)
       AND field LIKE 'quotaleft'
       AND actionID = 1636
       AND criteria > 0) AND
SomeModule::Loader init!
SomeModule::Loader init!
SomeModule::Loader init!
SomeModule::Loader init!
SomeModule::Loader init!
Can't return outside a subroutine, <SOCKET> line 138.
Callback called exit, <SOCKET> line 138.

--------------------

now, i put the init warns in from of EVERY subroutine in the offending 
module...
you'll see the warns from previous lines, right up to 903... 904 is a blank, 
then 905 is a simple regex to slice off a trailing AND from the SQL 
statement we're trying to build... but the running never gets to the warn 
statement following the regular expression substitute... it never gets to 
the warns following line 905... but then we see a bunch of inits from an 
distantly related module not directly connected to this one (there is no 
call to it and no return this early), and them BANG, Callback called exit, 
etc... the page loads, but without the item from the db we tried to select 
and turn into an object.  Other areas of the site successfully use this same 
routine without this problem...

it makes no sense...

ideas are welcome.

~jet






ANNOUNCE: Embperl 2.0rc3
Gerald Richter 05:10 on 15 Mar 2005

Can't return outside a subroutine, <SOCKET> line 138.
jet 22:26 on 15 Mar 2005

Generated at 11:30 on 21 Mar 2005 by mariachi v0.52