Opened 13 years ago

Closed 10 years ago

#148 closed defect (fixed)

Empty page due to the use of unitialized value in substitution and pattern match.

Reported by: zephryus Owned by: naoki iimura
Priority: normal Milestone: 1.1.2
Component: User Interface Version: 1.1.1
Severity: normal Keywords: uninitialized value


Recently, I upgraded my POPfile version from v1.1.0 to v1.1.1

But now, I notice the following lines are dumped to the invoking console when I hit [filter] button or delete the page button sometimes and NOT always.

Use of uninitialized value in substitution (s///) at /extra/ishikawa/download/POPFILE-DIR//UI/ line 396.
Use of uninitialized value in substitution (s///) at /extra/ishikawa/download/POPFILE-DIR//UI/ line 251.
Use of uninitialized value in pattern match (m//) at /extra/ishikawa/download/POPFILE-DIR//UI/ line 253.

These are shown in triples whenever the mentioned problem appears.

  395	    if ( $command =~ /POST/i ) {
  396	        $content =~ s/[\r\n]//g;
  397	        $self->parse_form_( $content );

  251	    $arguments =~ s/&/&/g;
  253	    while ( $arguments =~ m/\G(.*?)=(.*?)(&|\r|\n|$)/g ) {
  254	        my $arg = $1;

And when such messages are dumped, the web GUI page shown anew is blank. If I reload the page (the browser shows the warning about resubmitting the request), then the new page is correctly shown with the listing of other messages if any, or an empty list, i.e., no matching message is there and so the list is empty.

I would think that the $argument in and $component in are already blank before the evaluation is done on each of the Perl source file lines. And maybe my perl setting is set to halt(?) when a strict checking raises an error or something. But I am not sure what the current perl setting is. The PC runs old Fedora distribution, but I upgraded the necessary Perl modules using CPAN and installed the POPfile script and such by downloading this from download page.


Change History (14)

comment:1 by Brian Smith, 13 years ago

Thank you for the bug report.

I use a modified version of POPFile on my Windows system and sometimes see a similar problem. I had thought the problem was caused by my modifications.

The problem does not happen very often (once every few months). I have not found a way to reproduce the problem. This makes it difficult to investigate the problem.

Which browser do you use to display the message history page?

On my Windows system I have found that some POPFile UI problems only appear when I use the Opera browser.

comment:2 by zephryus, 13 years ago

So it is not a problem seen by me only. What a relief :-)

I use Firefox browser from a different computer.

The POPFile runs on a different linux PC and I use Firefox browser on a linux guest inside a VirtualBox instance on a different PC (that runs XP).

Oh, by the way, I upgraded the perl installation on the PC where POPFile runs to see if it solves the problem. But I got the same error after I upgraded perl and so I suspect that the problem is in the POPFile itself.


comment:3 by naoki iimura, 13 years ago

Milestone: 1.1.2
Owner: changed from Manni Heumann to naoki iimura

I've updated UI/ to solve the problem: [3667] I hope the change works.


comment:4 by zephryus, 13 years ago

Thank you for the update.

I will check and see if the modification eliminates the problem. (But I have to download the special "branch" distribution, correct?)


comment:5 by Brian Smith, 13 years ago

Naoki only changed one file so all you need to do is add this file to your existing POPFile 1.1.1 installation.

Shutdown POPFile then replace the existing UI/ file with the new version.

If you make a backup copy of the original file (e.g. UI/ then it will be easy to go back to the original file if the new version does not work.

There are several ways to get the new file:

(1) You can download the latest popfile_0_22_2.tgz tarball and extract the new UI/ file

(2) You can use a Subversion client to download the new UI/ file from the b0_22_2 branch of the Subversion repository. See How to obtain the source code for further details, including the repository URLs

(3) You can use your browser to download the UI/ file from our source code browser using the "Original Format" link at the bottom of the page found at

Option (3) is probably the easiest way to get a single file from our Subversion repository.

comment:6 by zephryus, 13 years ago

Thank you for the pointer. I will change and report my findings. (This particular POPfile is installed on an office PC, and we are already on weekends in Japan.)

comment:7 by zephryus, 13 years ago

Dear naoki and brian,

Thank you for the patch and the pointer to apply the patch.

Well, a little progress.

Here is what I found out.

I downloaded the modified and replaced it, and restarted POPfile.

During my testing, one type of error is now reported occasionally like the following (now at one line of code) instead of at three locations.

POPFile Engine v1.1.1 running
Use of uninitialized value $content in substitution (s///) at /download/POPFILE-DIR//UI/ line 396.
Use of uninitialized value $content in substitution (s///) at /download/POPFILE-DIR//UI/ line 396.

If this error is reported after deleting a page-full of article from history, I get a blank page, and if I reload the page, I am now back to a non-empty LIST of the remaining articles (in a particular bucket).

Previously, if I recall correctly, most of the time, the blank screen goes back to the EMPTY list of the articles in a particular bucket after deleting a page full of articles. (That is I noticed the problem occurred when the remaining list after a deletion of articles is empty. But come to think of it, my memory may not be that great.)

Now, looking at, I suspect $content is also not-set(?) after a screenful of articles is deleted, and just before the next screenful was going to be displayed? I am not sure.

  395	    if ( $command =~ /POST/i ) {
  396		$content =~ s/[\r\n]//g;
  397		$self->parse_form_( $content );
  398	    }

this is in subroutine url_handler:

It is called thusly:

/download/POPFILE-DIR/UI/    $self->{url_handler_} = \&url_handler__;
/download/POPFILE-DIR/UI/ url_handler__ - Handle a URL request
/download/POPFILE-DIR/UI/ url_handler__
/download/POPFILE-DIR/UI/    return $self->{url_handler_}( $self, $client, $url, $command, $content );

Does the call to handle_url contain correct number of arguments? I bet.

>                        $code = $self->handle_url( $client, $2, $1, $content );
>                        $self->log_( 2,                                # PROFILE BLOCK START

Well, I am not sure what will fix the problem.

But if I added a few lines of code in like this, the problem is not seen at least for the day. (I have deleted all the spam articles from history during testing. So I can only check more tomorrow.)

sub url_handler__
    my ( $self, $client, $url, $command, $content ) = @_;

    if ( !defined $content ) {    # These are additions. 
	$content = '';            #
    }	                          # 

This seems like a bandage fix.

I don't follow the logic well, but what if $content_length is 0 when we hit the call of handle_url in here. Can $content be undefined or in an undesirable state???

                    if ( $content_length > 0 ) {
                        $content = $self->slurp_buffer_( $client,  # PROFILE BLOCK START
                            $content_length );                     # PROFILE BLOCK STOP
                        $self->log_( 2, $content );

                    if ( $request =~ /^(GET|POST) (.*) HTTP\/1\./i ) {
                        $code = $self->handle_url( $client, $2, $1, $content );
                        $self->log_( 2,                                # PROFILE BLOCK START
                            "HTTP handle_url returned code $code\n" ); # PROFILE BLOCK STOP
                    } else {

But reading the code, I don't see how it can be unset. Hmm...

Some kind of weird timing problem?

FYI, I am using a POPfile instance running on a linux PC, and then my TB3 (mail client) is running inside a linux guest inside Oracle Virtual Box under Windows XP on a different PC.

As a last resort, I can run wireshark or something to capture the packet to see what happens when the error is observed.


comment:8 by zephryus, 13 years ago

OK, I am not a perl hacker, but I found out that slurp_buffer that returns the data to $content CAN return "undef" value, it seems. See the definition in POPFile/

sub slurp_buffer_
    my ( $self, $handle, $length ) = @_;

    while ( $self->slurp_data_size__( $handle ) < $length ) {
        my $c;
        if ( $self->can_read__( $handle, 0.01 ) && ( sysread( $handle, $c, $length ) > 0 ) ) {
            $slurp_data__{"$handle"}{data} .= $c;
        } else {

    my $result = '';

    if ( $self->slurp_data_size__( $handle ) < $length ) {
        $result = $slurp_data__{"$handle"}{data};
        $slurp_data__{"$handle"}{data} = '';
    } else {
        $result = substr( $slurp_data__{"$handle"}{data}, 0, $length );
        $slurp_data__{"$handle"}{data} =                       # PROFILE BLOCK START
            substr( $slurp_data__{"$handle"}{data}, $length ); # PROFILE BLOCK STOP

    return ($result ne '')?$result:undef;

So for a reason unfathomable to me, the value of $result remains


, its initial value (assigned in the middle), at the end of the execution, then slurp_buffer decides to return "undef", which presumably causes the "Uniitialized" warning for the use of $content (!).

A suspicious behavior.

I will leave the rest to people in the know.

comment:9 by Brian Smith, 13 years ago

Thanks for the updates. Sorry to hear that you are still having trouble.

I installed the new file on my Windows system on Saturday 11 September and have not seen any console error or warning messages since then (it is now Wednesday 15 September).

I clear my HISTORY page several times a day. Perhaps the problem only shows up when there is more than one page of HISTORY. I will stop clearing my HISTORY to see if this makes any difference.


comment:10 by Brian Smith, 13 years ago

With over 400 messages in my HISTORY no console messages appeared as I tried using the UI to view, sort and delete messages. I used Single Message View and deleted messages using the checkboxes, remove page, remove all, search filters, bucket filters, inverted searches, and inverted bucket filters.

These tests were run on my Windows system using Naoki's patch and Perl 5.8.9 Build 826


comment:11 by naoki iimura, 12 years ago

It seems that the web browser sends invalid data (the header has non-zero Content-Length but POPFile does not receive any content).

I've written another patch for to return 400 (Bad Request) error if web browsers send such invalid requests. [3677]

You can get the new from here:

I hope the new code solves your problem.


comment:12 by zephryus, 12 years ago

Thank you for looking into this old problem. I have been using Firefox and am surprised to hear that it may send invalid data occasionally. But over the years, firefox suffered from many different bugs, and so come to think of it, it may be the cause of the problem.

Since Japan, where I live, is in the middle of long holiday week (people call it Golden Week), I will test the patch this Friday or Monday.

Strangely, I have not seen this bug for the last few months. (To be honest, I have come to rely on POPfile and most of the times, POPfile happily classifies incoming mails correctly. Only when a new correspondent starts with a new party with a different set of topics, I need to jump in and correct the notion of category POPfile has about certain e-mails. So the frequency of using web interface to POPfile has dwindled than before.)

This reduced frequency of the observation of the bug may be due to

  • less frequent use of POPfile GUI (like I explained above),
  • updates of firefox,
  • updates of Debian GNU/Linux under which firefox runs,
  • updates of VirtualBox in which the guest Debian GNU/Linux instance runs.

(Hmm, so many improvements or changes on the client side.)

POPfile runs on a different PC that runs old version of Fedora, but the versions of POPfile, Perl, OS have remained the same since my first report.

I will report back once the patch is applied and test is done.


comment:13 by zephryus, 11 years ago

This has been fixed in the long time between my last report and today.

Sorry to fail to update the bug entry! I just thought of submitting another bug report today, and while looking for a similar bug report, I stumbled upon my old bug entry.

Thank you again for making this great package available to wide community.

comment:14 by naoki iimura, 10 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.