Item13077: Configure crash "Not a HASH reference at ConfigurePlugin.pm line 160"

pencil
Priority: Urgent
Current State: Closed
Released In: n/a
Target Release:
Applies To: Engine
Component: Configure
Branches: master
Reported By: GeorgeClark
Waiting For:
Last Change By: GeorgeClark
Unexpected crash when error in regex parameters.

This might be the same issue that I run into occasionally when I remove LocalSite.cfg to rerun bootstrap. Configure then fails to load with a very similar crash. This particular error can be triggered by entering an invalid regex into the ConfigureFilter field. With various print statements, it appears that the REGEX.pm checker is never called - it doesn't get that far. But renaming REGEX.pm so that the checker doesn't exist bypasses the issue. This crash occurs when any regex is invalid, not just ConfigureFilter (Remove the trailing ) from the NameFilter for ex.

The crash (As much as I could copy/paste ... it goes off the bottom of the screen and I can't scroll or highlight it.):

Error
Not a HASH reference at /var/www/foswiki/distro/core/lib/Foswiki/Plugins/ConfigurePlugin.pm line 160.
at /var/www/foswiki/distro/core/lib/Foswiki/Plugins/ConfigurePlugin.pm line 159.
Foswiki::Plugins::ConfigurePlugin::__ANON__('Foswiki=HASH(0x88ba9d8)', 'Foswiki::Contrib::JsonRpcContrib::Request=HASH(0x8ebd930)', 'Foswiki::Response=HASH(0x88ba908)', undef) called at /var/www/foswiki/distro/core/lib/Foswiki/Contrib/JsonRpcContrib/Server.pm line 166
Foswiki::Contrib::JsonRpcContrib::Server::__ANON__() called at /usr/lib/perl5/vendor_perl/5.18.2/Error.pm line 419
eval {...} called at /usr/lib/perl5/vendor_perl/5.18.2/Error.pm line 411
Error::subs::try('CODE(0x8ee3970)', 'HASH(0x8e395c8)') called at /var/www/foswiki/distro/core/lib/Foswiki/Contrib/JsonRpcContrib/Server.pm line 180
Foswiki::Contrib::JsonRpcContrib::Server::dispatch('Foswiki::Contrib::JsonRpcContrib::Server=HASH(0x8da2208)', 'Foswiki=HASH(0x88ba9d8)') called at /var/www/foswiki/distro/core/lib/Foswiki/Contrib/JsonRpcContrib.pm line 38
Foswiki::Contrib::JsonRpcContrib::dispatch('Foswiki=HASH(0x88ba9d8)') called at /var/www/foswiki/distro/core/lib/Foswiki/UI.pm line 372
Foswiki::UI::__ANON__() called at /usr/lib/perl5/vendor_perl/5.18.2/Error.pm line 419
eval {...} called at /usr/lib/perl5/vendor_perl/5.18.2/Error.pm line 411
Error::subs::try('CODE(0x804dd58)', 'HASH(0x88bad28)') called at /var/www/foswiki/distro/core/lib/Foswiki/UI.pm line 498
Foswiki::UI::_execute('Foswiki::Request=HASH(0x80f93a8)', 'CODE(0x82932c8)', 'jsonrpc', 1) called at /var/www/foswiki/distro/core/lib/Foswiki/UI.pm line 324
Foswiki::UI::handleRequest('Foswiki::Request=HASH(0x80f93a8)') called at /var/www/foswiki/distro/core/lib/Foswiki/Engine/CGI.pm line 91
Foswiki::Engine::CGI::run('Foswiki::Engine::CGI=HASH(0x828b420)') called

This same issue seems to happen on occasion before any config has been entered. Remove LocalSite.cfg, hit bin/view url, click configure link, the configure page paints, "spinner" starts, but no tabs paint, and the same Not a HASH ref happens.

-- GeorgeClark - 06 Nov 2014

Probably most importantly, something is masking the actual issue. I believe that the "Not a HASH" occurs because something else failed. But the underlying cause was masked. If the regex trigger is fixed, it's still important to somehow report whatever caused the $response to be undefined.

For some debugging, I added some print statements, and when a REGEX field has a syntax error:

        no strict 'refs';
        my $response = eval { &$method( $request->params(), $reporter ); };
        print STDERR Data::Dumper::Dumper( \$@ );                     #<< Prints $VAR1 = \'' 
        use strict 'refs';
        use Data::Dumper;
        print STDERR Data::Dumper::Dumper( \$response );         #<< Prints $VAR1 = \undef;

        unless ($response) {
            print STDERR Data::Dumper::Dumper( \$response );      #<< Prints $VAR1 = \undef;
            print STDERR Data::Dumper::Dumper( \$_ );                   #<<  Prints $VAR1 = \'$Foswiki::engine->run();

            die join( "\n",
                map { "$_->{level}: $_->{text}" } $reporter->messages() );
        }
        return $response;
      }

I think part of the issue is that $_ is always set to \'$Foswiki::engine->run();, so accessing $_->{level} isn't going to work. But I'm not sure how to fix it.

AH HA... I also added a dump for $reporter:

$VAR1 = \bless( {
                   'messages' => [
                                   {
                                     'text' => 'The value of {ConfigureFilter} was unreadable: <verbatim>Unmatched ( in regex; marked by <-- HERE in m/( <-- HERE ?^:^(AaaronBBB|JoeUser|Freds|BaseUserMapping_333)/</verbatim>',
                                     'level' => 'errors'
                                   }
                                 ],
                   'changes' => {}
                 }, 'Foswiki::Configure::Reporter' );

So the message is there, but the code to map it isn't correct. I removed the map, and changed it to simply "die $reporter->messages(); But that doesn't do it. There is still no response object, so nothing makes it back to the UI, it just sits with the spinner spinning. Nothing is logged to apache error.log except for the print statements I added. And nothing is logged to the foswiki error log either.

At this point I have no idea where to go. Something is suppressing the failure debugging and the Foswiki::Response object disappears, so nothing can get back to the interface. I didn't have asserts enabled, so I added that, but no difference. Completely devoid of debug info.

Okay one more bit of info. With the map removed from the "die", the response from firebug is an "Unspecified internal error" from Foswiki/UI.pm: line 493. But this is still all after the fact, as the $response disappeared somehow.

I give up ... not a clue where to go from here.

-- GeorgeClark - 06 Nov 2014

Okay, configure crash came back. It's an issue in BOOLGROUP. However there really are two issues. Spec failures should not cause the $response object to go away, resulting in a "not a HASH Ref" failure.

                                    'text' => '/var/www/foswiki/distro/core/lib/Foswiki/Contrib/LogDispatchContrib/Config.spec: 167: Bad option \'ndelay\' in .spec before ,noeol,nofatal,nonul,nowait,perror,pid DISPLAY_IF="{Log}{LogDispatch}{Syslog}{Enabled}" at /var/www/foswiki/distro/core/lib/Foswiki/Configure/Item.pm line 153.
 at /usr/lib/perl5/vendor_perl/5.18.2/CGI/Carp.pm line 378, <$fh> line 167.
        CGI::Carp::realdie(\'Bad option \\\'ndelay\\\' in .spec before ,noeol,nofatal,nonul,no...\') called at /usr/lib/perl5/vendor_perl/5.18.2/CGI/Carp.pm line 467
        CGI::Carp::die(\'Bad option \\\'ndelay\\\' in .spec before ,noeol,nofatal,nonul,no...\') called at /var/www/foswiki/distro/core/lib/Foswiki/Configure/Item.pm line 153
        Foswiki::Configure::Item::_parseOptions(\'Foswiki::Configure::Value=HASH(0x96a0d30)\', \'EXPERT ndelay,noeol,nofatal,nonul,nowait,perror,pid DISPLAY_I...\') called at /var/www/foswiki/distro/core/lib/Foswiki/Configure/Item.pm line 100
        Foswiki::Configure::Item::set(\'Foswiki::Configure::Value=HASH(0x96a0d30)\', \'typename\', \'BOOLGROUP\', \'keys\', \'\', \'opts\', \'EXPERT ndelay,noeol,nofatal,nonul,nowait,perror,pid DISPLAY_I...\', \'defined_at\', \'ARRAY(0x96a5ee0)\', ...) called at /var/www/foswiki/distro/core/lib/Foswiki/Configure/Item.pm line 50
        Foswiki::Configure::Item::new(\'Foswiki::Configure::Value\', \'typename\', \'BOOLGROUP\', \'keys\', \'\', \'opts\', \'EXPERT ndelay,noeol,nofatal,nonul,nowait,perror,pid DISPLAY_I...\', \'defined_at\', \'ARRAY(0x96a5ee0)\', ...) called at /var/www/foswiki/distro/core/lib/Foswiki/Configure/Value.pm line 109
        Foswiki::Configure::Value::new(\'Foswiki::Configure::Value\', \'BOOLGROUP\', \'opts\', \'EXPERT ndelay,noeol,nofatal,nonul,nowait,perror,pid DISPLAY_I...\', \'defined_at\', \'ARRAY(0x96a5ee0)\') called at /var/www/foswiki/distro/core/lib/Foswiki/Configure/LoadSpec.pm line 308
        eval {...} called at /var/www/foswiki/distro/core/lib/Foswiki/Configure/LoadSpec.pm line 307
        Foswiki::Configure::LoadSpec::parse(\'/var/www/foswiki/distro/core/lib/Foswiki/Contrib/LogDispatchC...\', \'Foswiki::Configure::Root=HASH(0x8f44120)\', \'Foswiki::Configure::Reporter=HASH(0x8f242f0)\') called at /var/www/foswiki/distro/core/lib/Foswiki/Configure/LoadSpec.pm line 146
        Foswiki::Configure::LoadSpec::_loadSpecsFrom(\'/var/www/foswiki/distro/core/lib/Foswiki/Contrib\', \'Foswiki::Configure::Root=HASH(0x8f44120)\', \'HASH(0x8947ac0)\', \'Foswiki::Configure::Reporter=HASH(0x8f242f0)\') called at /var/www/foswiki/distro/core/lib/Foswiki/Configure/LoadSpec.pm line 126
        Foswiki::Configure::LoadSpec::readSpec(\'Foswiki::Configure::Root=HASH(0x8f44120)\', \'Foswiki::Configure::Reporter=HASH(0x8f242f0)\') called at /var/www/foswiki/distro/core/lib/Foswiki/Configure/Query.pm line 236
        Foswiki::Configure::Query::getspec(\'HASH(0x8e0e218)\', \'Foswiki::Configure::Reporter=HASH(0x8f242f0)\') called at /var/www/foswiki/distro/core/lib/Foswiki/Plugins/ConfigurePlugin.pm line 157
        Foswiki::Plugins::ConfigurePlugin::__ANON__(\'Foswiki=HASH(0x881be98)\', \'Foswiki::Contrib::JsonRpcContrib::Request=HASH(0x8f23478)\', \'Foswiki::Response=HASH(0x881bf68)\', undef) called at /var/www/foswiki/distro/core/lib/Foswiki/Contrib/JsonRpcContrib/Server.pm line 166
        Foswiki::Contrib::JsonRpcContrib::Server::__ANON__() called at /usr/lib/perl5/vendor_perl/5.18.2/Error.pm line 419
        eval {...} called at /usr/lib/perl5/vendor_perl/5.18.2/Error.pm line 411
        Error::subs::try(\'CODE(0x8f234b8)\', \'HASH(0x8f243b0)\') called at /var/www/foswiki/distro/core/lib/Foswiki/Contrib/JsonRpcContrib/Server.pm line 180
        Foswiki::Contrib::JsonRpcContrib::Server::dispatch(\'Foswiki::Contrib::JsonRpcContrib::Server=HASH(0x8de28e8)\', \'Foswiki=HASH(0x881be98)\') called at /var/www/foswiki/distro/core/lib/Foswiki/Contrib/JsonRpcContrib.pm line 38
        Foswiki::Contrib::JsonRpcContrib::dispatch(\'Foswiki=HASH(0x881be98)\') called at /var/www/foswiki/distro/core/lib/Foswiki/UI.pm line 372
        Foswiki::UI::__ANON__() called at /usr/lib/perl5/vendor_perl/5.18.2/Error.pm line 419
        eval {...} called at /usr/lib/perl5/vendor_perl/5.18.2/Error.pm line 411
        Error::subs::try(\'CODE(0x804dd58)\', \'HASH(0x8776190)\') called at /var/www/foswiki/distro/core/lib/Foswiki/UI.pm line 498
        Foswiki::UI::_execute(\'Foswiki::Request=HASH(0x8773138)\', \'CODE(0x8772f78)\', \'jsonrpc\', 1) called at /var/www/foswiki/distro/core/lib/Foswiki/UI.pm line 324
        Foswiki::UI::handleRequest(\'Foswiki::Request=HASH(0x8773138)\') called at /var/www/foswiki/distro/core/lib/Foswiki/Engine/CGI.pm line 91
        Foswiki::Engine::CGI::run(\'Foswiki::Engine::CGI=HASH(0x82d3278)\') called at jsonrpc line 44

I can't reproduce this. How?

-- CrawfordCurrie - 03 Dec 2014

Make a typo in any regex type field, and click outside to trigger a check. Here is an easy example. Right from bootstrap, don't even need to save the config. Security and Authentication -> Access Control and enter ^($ into the ConfigureFilter field (mismatched parenthesis in a regex)

Not a HASH reference at /var/www/foswiki/distro/core/lib/Foswiki/Plugins/ConfigurePlugin.pm line 160.
at /var/www/foswiki/distro/core/lib/Foswiki/Plugins/ConfigurePlugin.pm line 159.
Foswiki::Plugins::ConfigurePlugin::__ANON__('Foswiki=HASH(0x889e2e0)', 'Foswiki::Contrib::JsonRpcContrib::Request=HASH(0x8efb080)', 'Foswiki::Response=HASH(0x889e210)', undef) called at /var/www/foswiki/distro/core/lib/Foswiki/Contrib/JsonRpcContrib/Server.pm line 175
Foswiki::Contrib::JsonRpcContrib::Server::__ANON__() called at /usr/lib/perl5/vendor_perl/5.18.2/Error.pm line 419
...

-- GeorgeClark - 03 Dec 2014
 
Topic revision: r11 - 11 Dec 2014, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy