[Mimedefang] Undefined subroutine &MIME::QuotedPrint::encode_qp

David Eisner cradle at umd.edu
Fri Feb 10 19:29:05 EST 2006


More detective work.  Same system as with the last problem:

Centos 3.6 Linux box, and some version information relevant to this problem:

  mimedefang-2.55
  Mail-SpamAssassin-3.1.0
  MIME-tools-5.419
  MIME::QuotedPrint  3.07
  MIME-Base64-3.07

I have mimedefang up and running on the test box.  I occasionally get 
errors like this in the maillog:

     mimedefang-multiplexor[30296]: Slave 1 stderr: Undefined subroutine 
&MIME::QuotedPrint::encode_qp called at (eval 846) line 1.

This seems to occur with a certain type of spam (with Content-Type: 
text/html;charset="GB2312" sections.)

With judicious use of mimedefang's -d switch, I was able to get a 
snapshot of the working directory in the mimedefang spool for one of the 
offending spams.  I ran mimedefang.pl through the perl debugger, and 
produced this stack trace.  The line numbers in mimedefang.pl may be a 
bit off because I added some md_syslog statments when I was trying to 
narrow down the scope of the error.  Here you go:

DB<13> n
Undefined subroutine &MIME::QuotedPrint::encode_qp called at (eval 
68)[/usr/lib/perl5/site_perl/5.8.0/MIME/Decoder/QuotedPrint.pm:78] line 1.
    MIME::Decoder::QuotedPrint::encode_qp_threearg('Spam detection 
software, running on the system "ldap.calce.um...','undef',1) called at 
/usr/lib/perl5/site_perl/5.8.0/MIME/Decoder/QuotedPrint.pm line 95
    MIME::Decoder::QuotedPrint::encode_qp_really('Spam detection 
software, running on the system "ldap.calce.um...','undef') called at 
/usr/lib/perl5/site_perl/5.8.0/MIME/Decoder/QuotedPrint.pm line 154
 MIME::Decoder::QuotedPrint::encode_it('MIME::Decoder::QuotedPrint=HASH(0xaf945d0)','IO::ScalarArray=GLOB(0xaf94738)','IO::Wrap=REF(0xa39b748)','undef') 
called at /usr/lib/perl5/site_perl/5.8.0/MIME/Decoder.pm line 263  
MIME::Decoder::encode('MIME::Decoder::QuotedPrint=HASH(0xaf945d0)','IO::ScalarArray=GLOB(0xaf94738)','IO::Wrap=REF(0xa39b748)') 
called at /usr/lib/perl5/site_perl/5.8.0/MIME/Entity.pm line 1860
    
MIME::Entity::print_bodyhandle('MIME::Entity=HASH(0xa8b27f4)','IO::Wrap=REF(0xa39b748)') 
called at /usr/lib/perl5/site_perl/5.8.0/MIME/Entity.pm line 1830
    
MIME::Entity::print_body('MIME::Entity=HASH(0xa8b27f4)','IO::Wrap=REF(0xa39b748)') 
called at /usr/lib/perl5/site_perl/5.8.0/MIME/Entity.pm line 1750
    
MIME::Entity::print('MIME::Entity=HASH(0xa8b27f4)','IO::Wrap=REF(0xa39b748)') 
called at /usr/lib/perl5/site_perl/5.8.0/MIME/Entity.pm line 1803
    
MIME::Entity::print_body('MIME::Entity=HASH(0xa388d04)','GLOB(0x907f3d4)') 
called at /usr/local/bin/mimedefang.pl line 5743
    main::do_scan(.) called at /usr/local/bin/mimedefang.pl line 5143
    main::main called at /usr/local/bin/mimedefang.pl line 7365
Debugged program terminated.  Use q to quit or R to restart,
use O inhibit_exit to avoid stopping after program termination,
h q, h R or h O to get additional info. 


Still with me?  So the error is occurring here, in 
MIME/Decoder/QuotedPrint.pm, line 78:

     64 #------------------------------
     65 # If we have MIME::QuotedPrint 3.03 or later, use the three-argument
     66 # version.  If we have an earlier version of MIME::QuotedPrint, we
     67 # may get the wrong results.  However, on some systems (RH Linux,
     68 # for example), MIME::QuotedPrint is part of the Perl package and
     69 # upgrading it separately breaks their magic auto-update tools.
     70 # We are supporting older versions of MIME::QuotedPrint even though
     71 # they may give incorrect results simply because it's too painful
     72 # for many people to upgrade.
     73
     74 # The following code is horrible.  I know.  Beat me up. --dfs
     75 BEGIN {
     76     if (!defined(&encode_qp_threearg)) {
     77         if ($::MIME::QuotedPrint::VERSION >= 3.03) {
     78             eval 'sub encode_qp_threearg ( $$$ ) { 
encode_qp(shift, shift, shift); }';
     79         } else {
     80             eval 'sub encode_qp_threearg ( $$$ ) { 
encode_qp(shift); }';
     81         }
     82     }
     83 }


And here is the relevant part of MIME::QuotedPrint on my system, where 
there is some typeglob magic going on :


-------------------snip---8<-----------------
package MIME::QuotedPrint;

# $Id: QuotedPrint.pm,v 3.7 2005/11/29 20:49:46 gisle Exp $

use strict;
use vars qw(@ISA @EXPORT $VERSION);

require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(encode_qp decode_qp);

$VERSION = "3.07";

use MIME::Base64;  # will load XS version of {en,de}code_qp()

*encode = \&encode_qp;
*decode = \&decode_qp;

1;

__END__
 -------------------snip---8<-----------------

I noticed that I have two MIME::Base64 perl modules on my system:

/usr/lib/perl5/site_perl/5.8.0/MIME/Base64.pm  ---> VERSION 2.12
/usr/lib/perl5/5.8.0/i386-linux-thread-multi/MIME/Base64.pm  --> 
VERSION  3.07

I installed MIME-Base64-3.07, and it appears to have installed in the 
second location.  I think this is the version that is being used:

$ perl -e 'use MIME::QuotedPrint; print "$::MIME::QuotedPrint::VERSION 
$::MIME::Base64::VERSION\n"'
3.07 3.07



OK, finally, from MIME::Base64:

-------------------snip---8<-----------------
package MIME::Base64;

# $Id: Base64.pm,v 3.11 2005/11/29 20:59:55 gisle Exp $

use strict;
use vars qw(@ISA @EXPORT $VERSION);

require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(encode_base64 decode_base64);

$VERSION = '3.07';

require XSLoader;
XSLoader::load('MIME::Base64', $VERSION);

*encode = \&encode_base64;
*decode = \&decode_base64;

1;

__END__
-------------------snip---8<-----------------

I don't see where encode_qp is getting defined.  I assume it happens in 
XSLoader::load() somewhere.

I'm at the end of my perl knowledge here.  Maybe encode_qp is out of 
scope in the eval in Decoder::QuotedPrint for some reason, or perhaps 
the XSLoader::load() method is picking up the older MIME::Base64.  Maybe 
I'll temporarily move it and see what happens (but I need some dinner 
now.) 

OK, I lied, I deleted the older MIME::Base64 and it worked!  I dont' 
have the heart to delete this email.  New question:  why is it picking 
up the older version of that module?  I followed the directions in the 
HOWTO.  Should MIME-Base64-3.07 have installed into both locations?

-David












More information about the MIMEDefang mailing list