Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#179 closed defect (fixed)

Error in early exit processing path.: Can't call method "finish" without a package or object reference ...

Reported by: zephryus Owned by: Brian Smith
Priority: low Milestone: 1.1.4
Component: unknown Version: 1.1.3
Severity: normal Keywords:
Cc:

Description

Error in early exit processing path.:

There seems to be an error in the processing of exit path when an already-running POPfile image is found. A run time error, "Can't call method "finish" without a package or object reference ..." is printed on the terminal window where POPfile is invoked.

The Bayes.pm line 1273 mentioned in the console message below is as follows:

 1269	sub db_disconnect__
 1270	{
 1271	    my ( $self ) = @_;
 1272	
*1273	    $self->{db_get_buckets__}->finish;
 1274	    $self->{db_get_wordid__}->finish;
 1275	    $self->{db_get_userid__}->finish;
 1276	    $self->{db_get_word_count__}->finish;

(Maybe the order of stopping various modules is not quite right when already-running POPfile is found, and POPfile invocation is terminated early? So that the db_get_buckets above actually is NULL when the above code gets executed in this early exit path?)

This is under linux.

--- starting script ---
:
#
PD=/extra/ishikawa/download/POPFILE-DIR

POPFILE_USER=$PD/
POPFILE_ROOT=$PD/

export POPFILE_USER POPFILE_ROOT
perl $PD/popfile.pl \
     --set html_language=Nihongo \
     --set html_local=0 \
     --set html_port=9090 \
     --set pop3_port=1110

----- end of starting script

The console log after Invoking starting script from a terminal window:

POPFile Engine loading

    Loading... 
	 {core: config mq logger history} 
	 {classifier: bayes wordmangle} 
	 {interface: xmlrpc html} 
	 {proxy: pop3 nntp smtp} 
	 {services: imap} 

POPFile Engine v1.1.3 starting

    Initializing... 
	 {core: config history logger mq} 
	 {classifier: bayes wordmangle} 
	 {interface: html xmlrpc} 
	 {proxy: nntp pop3 smtp} 
	 {services: imap} 

    Starting...     


A copy of POPFile appears to be running.
 Attempting to signal the previous copy.
 Waiting 10 seconds for a reply.

 A copy of POPFile is running.
 It has signaled that it is alive with process ID: 24792
Failed to start while starting the config module at /extra/ishikawa/download/POPFILE-DIR//POPFile/Loader.pm line 748.
	 {core:

POPFile Engine v1.1.3 stopping

    Stopping... 
	 {classifier: bayesCan't call method "finish" without a package or object reference at /extra/ishikawa/download/POPFILE-DIR//Classifier/Bayes.pm line 1273.

Indeed a POPfile is running in the background by the way:

debian-vbox-ci:/home/ishikawa# ps -aef | grep -i pop
root      7488  7276  0 16:10 pts/6    00:00:00 grep -i pop
lp       23181 23177  0 07:36 ?        00:00:00 gs -q -dNOPAUSE -dBATCH -dSAFER -sDEVICE=ps2write -sOUTPUTFILE=%stdout -dLanguageLevel=3 -r600 -dCompressFonts=false -dNoT3CCITT -c save pop -f /var/spool/cups/tmp/05a895075f4bd
root     24792 24791  0  9月19 ?       01:14:33 perl /extra/ishikawa/download/POPFILE-DIR/popfile.pl --set html_language=Nihongo --set html_local=0 --set html_port=9090 --set pop3_port=1110

Attachments (1)

t.diff (2.8 KB ) - added by zephryus 11 years ago.
Patch to fix the error/warning during early exit due to another copy of POPfile already running

Download all attachments as: .zip

Change History (6)

comment:1 by Brian Smith, 11 years ago

Owner: set to Brian Smith
Status: newassigned

Thank you for reporting this problem. It also happens in the Windows versions of POPFile 1.1.2 and 1.1.3.

The Windows version of POPFile 1.1.1 does not have this problem. Here are examples from POPFile 1.1.1 and 1.1.2 showing what happens when another copy of POPFile is started:

POPFile 1.1.1 (Windows version)

A copy of POPFile appears to be running.
 Attempting to signal the previous copy.
 Waiting 10 seconds for a reply.

 A copy of POPFile is running.
 It has signaled that it is alive with process ID: 5192
Failed to start while starting the config module at C:\Temp\111\program/POPFile/Loader.pm line 713.
} 
         {services:} 

    Starting...     
         {core:

------------------------------------------------------------
Status code: 9
------------------------------------------------------------

POPFile 1.1.2 (Windows version)

A copy of POPFile appears to be running.
 Attempting to signal the previous copy.
 Waiting 10 seconds for a reply.

 A copy of POPFile is running.
 It has signaled that it is alive with process ID: 2816
Failed to start while starting the config module at C:\temp\112\program/POPFile/Loader.pm line 750.
} 
         {services:} 

    Starting...     
         {core:

POPFile Engine v1.1.2 stopping

    Stopping... 
         {classifier: bayesCan't call method "finish" without a package or object reference at C:\temp\112\program/Classifier/Bayes.pm line 1273.

------------------------------------------------------------
Status code: 9
------------------------------------------------------------

Although the Bayes.pm in POPFile 1.1.2 is not the same as the one in POPFile 1.1.1, both files use the same code for the "db_disconnect__" function. Perhaps the problem is in one of the other changes between these two releases?

comment:2 by Brian Smith, 11 years ago

Perhaps the problem is in one of the other changes between these two releases?

I think the problem may be connected with some of the changes made to improve the way fatal errors are handled by POPFile.

When another copy of POPFile is found to be running, the second copy shuts down and exits. I suspect it tries to shut down some things that had not been yet started (the "Is there another copy running?" test occurs during the startup sequence).

I'm not a Perl programmer so I'm not sure how to fix this. Perhaps Loader.pm and/or Configuration.pm need to be changed?

by zephryus, 11 years ago

Attachment: t.diff added

Patch to fix the error/warning during early exit due to another copy of POPfile already running

comment:3 by zephryus, 11 years ago

You are right. As I also suspected that some data structures that would have been initialized during normal startup have not initialized when another copy of POPfile is detected and early exit path is taken.

So during shutting down of various modules, these uninitialized data structures caused run-time warnings and errors to be printed.

I did a bandage to Bayes.pm and History.pm (History.pm caused uninitialized variable warning to be printed once I fixed Bayes.pm).

These are bandage solutions, but at least it works for now. But someone who maintains the codebase ought to look at the checking of initialization in Bayes.pm: I took the short cut and always assume that the database is connected as soon as the subroutine to connect to DB is called (and not checking in detail whether the connection actually succeeded.)

I can create a wrapper function and set the status variable $_is_db_connected, there, but I thought it was an overkill.

It is right that the caller side ought to check for these situations as well, but as a start, the checks put into the called functions are good style also (defensive programming).

Also, I modified the error message when POPfile dies due to another copy already running so that the final log now looks like the following. (I am attaching the patch to a few files in the next post).

# bin/run-popfile.sh

POPFile Engine loading

    Loading... 
         {core: config mq logger history} 
         {classifier: bayes wordmangle} 
         {interface: xmlrpc html} 
         {proxy: pop3 nntp smtp} 
         {services: imap} 

POPFile Engine v1.1.3 starting

    Initializing... 
         {core: config history logger mq} 
         {classifier: bayes wordmangle} 
         {interface: html xmlrpc} 
         {proxy: nntp pop3 smtp} 
         {services: imap} 

    Starting...     
         {core:

A copy of POPFile appears to be running.
 Attempting to signal the previous copy.
 Waiting 10 seconds for a reply.

 A copy of POPFile is running.
 It has signaled that it is alive with process ID: 12110

Failed to start while starting the `config' module.
So stopping all module(s) and then die...


POPFile Engine v1.1.3 stopping

    Stopping... 
         {classifier: bayes wordmangle} 
         {core: config history logger mq} 
         {interface: html xmlrpc} 
         {proxy: nntp pop3 smtp} 
         {services: imap} 

POPFile Engine v1.1.3 terminated


comment:4 by naoki iimura, 11 years ago

Resolution: fixed
Status: assignedclosed

Thanks for the information.

I've fixed the bug: [3836]

Naoki

comment:5 by naoki iimura, 11 years ago

Milestone: 1.1.4
Note: See TracTickets for help on using tickets.