Weird error with SQL lookups in amavisd

Mark Martinec Mark.Martinec+amavis at ijs.si
Fri Apr 13 02:49:21 CEST 2012


Guus,

> I upgraded my smtp box from Fedora 13 to Fedora 15, also upgraded amavisd
> in the process.
> 
> According to amavisd, I'm now at 2.6.6, and I keep getting the following
> errors:
> Apr 12 15:07:02 smtp amavis[10332]: (10332-02) (!)lookup_sql: Can't use an
> undefined value as an ARRAY reference at (eval 78) line 257, <GEN20> line
> 3., ,
> Apr 12 15:07:02 smtp amavis[10332]: (10332-02) (!!)TROUBLE in
> process_request: Can't use an undefined value as an ARRAY reference at
> (eval 78) line 257, <GEN20> line 3. at (eval 78) line 282, <GEN20> line 3.
> Apr 12 15:07:02 smtp amavis[10332]: (10332-02) (!)Requesting process
> rundown after fatal error
> 
> Now, I don't know which eval this is, but I'm pretty sure, it's the one
> from line 9568 in sub process_request, from package Amavis.
> 
> I've got $lookup_sql_dsn configured with workable connection data, so the
> eval mentioned above will use the SQL bits from line 9633 onwards. One of
> them must throw the error... Don't know which one though...
> 
> If you want to see my table structure, I can certainly get a picture out,
> but it is the one detailed in the attached sql file.
> 
> Anybody seen this or has a solution, or even a way of figuring out what
> Perl actually means to say with "eval 78" <GEN20>, line 257, line 282, or
> line 3?

Lines 257 and 282 are relative to a package Amavis::Lookup::SQLfield,
counting from a __DATA__ line.

Search forward for:
  sub lookup_sql(
then search backwards for:
  __DATA__
then go down 257 lines, arriving at or near:
      $match = {}; @$match{@names} = @$a_ref;

The 282 then corresponds to a
    die $err;
a bit further down, which caught the eval failure and
propagated it further.

This is the area in question:

    $conn_h->execute($sel, at pos_args);  # do the query
    # fetch query results
    while ( defined($a_ref=$conn_h->fetchrow_arrayref($sel)) ) {
      my(@names) = @{$conn_h->sth($sel)->{NAME_lc}};
      $match = {}; @$match{@names} = @$a_ref;
      if ($self->{clause_name} eq 'sel_policy' &&
          !exists $match->{'local'} && $match->{'email'} eq '@.') {
[...]
  } or do {
    my($err) = $@ ne '' ? $@ : "errno=$!";  chomp $err;
    do_log(-1, "lookup_sql: %s, %s, %s", $err, $DBI::err, $DBI::errstr);
    die $err  if $err =~ /^timed out\b/;  # resignal timeout
    die $err;
  };


> lookup_sql: Can't use an undefined value as an ARRAY reference
> at (eval 78) line 257

Puzzling. The   "while (defined($a_ref..."   should ensure that
we only enter the loop when $a_ref is defined, yet the @$a_ref
appparently thinks it is undefined. I could be wrong by a line or two,
but this is the area that needs to be investigated. I don't see
what could be wrong there, nor do I remember seeing a similar report.

Perhaps adding a couple of calls to do_log in that area would
shed some light on the problem.

Btw, which version of perl is running now, and which version
of amavisd was running before the upgrade.

  Mark


More information about the amavis-users mailing list