Item11385: List iterator fails on undef lists.

Priority: Normal
Current State: Closed
Released In: 1.1.5
Target Release: patch
Applies To: Extension
Component: FoswikiIterator
Branches: Release01x01 trunk
Reported By: JayenAshar
Waiting For:
Last Change By: GeorgeClark
I upgraded to Foswiki 1.1.4 and then to LdapContrib 4.32 and this checkin broke my site. Reverting the patch with wget 'http://trac.foswiki.org/changeset/13472/trunk/LdapContrib?format=diff&new=13472' -O- | patch -p2 -R fixed the site.

I modified ListIterator.pm to get a backtrace:
| 2011-12-22T07:47:21Z warning | this list undefined at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/ListIterator.pm line 153
   Foswiki::ListIterator::all('Foswiki::ListIterator=HASH(0x9183b54)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/Users/LdapUserMapping.pm line 361
   Foswiki::Users::LdapUserMapping::eachGroupMember('Foswiki::Users::LdapUserMapping=HASH(0x9b5ff84)', 'IDM_STF_SCI_CQCT', 'HASH(0x9183b44)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/UserMapping.pm line 401
   Foswiki::UserMapping::isInGroup('Foswiki::Users::LdapUserMapping=HASH(0x9b5ff84)', 'BaseUserMapping_666', 'IDM_STF_SCI_CQCT', 'HASH(0x9b6cb34)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/Users.pm line 850
   Foswiki::Users::isInGroup('Foswiki::Users=HASH(0x9b269e4)', 'BaseUserMapping_666', 'IDM_STF_SCI_CQCT') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/Users.pm line 636
   Foswiki::Users::isInUserList('Foswiki::Users=HASH(0x9b269e4)', 'BaseUserMapping_666', 'ARRAY(0x9ac8c1c)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/Meta.pm line 1821
   Foswiki::Meta::haveAccess('Foswiki::Meta=HASH(0x9b65c7c)', 'VIEW') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/WebFilter.pm line 47
   Foswiki::WebFilter::ok('Foswiki::WebFilter=HASH(0x9b46d0c)', 'Foswiki=HASH(0x9b26a64)', 'Main/CQC2T') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki.pm line 1549
   Foswiki::deepWebList('Foswiki=HASH(0x9b26a64)', 'Foswiki::WebFilter=HASH(0x9b46d0c)', undef) called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/Macros/WEBLIST.pm line 45
   Foswiki::WEBLIST('Foswiki=HASH(0x9b26a64)', 'Foswiki::Attrs=HASH(0x9b59b34)', 'Foswiki::Meta=HASH(0x99b6d4c)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki.pm line 3071
   Foswiki::_expandMacroOnTopicRendering('Foswiki=HASH(0x9b26a64)', 'WEBLIST', '"   * <span style=\"white-space:nowrap\"><a href=\"/$name/Web...', 'Foswiki::Meta=HASH(0x99b6d4c)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki.pm line 2947
   Foswiki::_processMacros('Foswiki=HASH(0x9b26a64)', '   * *%MAKETEXT{"Webs"}%*\x{a}%WEBLIST{"   * <span style=\"white-...', 'CODE(0x8a965bc)', 'Foswiki::Meta=HASH(0x99b6d4c)', 16) called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki.pm line 2744
   Foswiki::innerExpandMacros('Foswiki=HASH(0x9b26a64)', 'SCALAR(0x9b65b0c)', 'Foswiki::Meta=HASH(0x99b6d4c)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/Macros/INCLUDE.pm line 296
   Foswiki::__ANON__() called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/CPAN/lib/Error.pm line 379
   eval {...} called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/CPAN/lib/Error.pm line 371
   Error::subs::try('CODE(0x8b2be1c)', 'HASH(0x9b65cfc)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/Macros/INCLUDE.pm line 343
   Foswiki::INCLUDE('Foswiki=HASH(0x9b26a64)', 'Foswiki::Attrs=HASH(0x9ac8bec)', 'Foswiki::Meta=HASH(0x9b25c1c)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki.pm line 3071
   Foswiki::_expandMacroOnTopicRendering('Foswiki=HASH(0x9b26a64)', 'INCLUDE', ' "System.WebLeftBarWebsList" ', 'Foswiki::Meta=HASH(0x9b25c1c)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki.pm line 2947
   Foswiki::_processMacros('Foswiki=HASH(0x9b26a64)', '%INCLUDE{"%IF{"context can_login" then="%SYSTEMWEB%.WebLeftBa...', 'CODE(0x8a965bc)', 'Foswiki::Meta=HASH(0x9b25c1c)', 16) called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki.pm line 2744
   Foswiki::innerExpandMacros('Foswiki=HASH(0x9b26a64)', 'SCALAR(0x9ac872c)', 'Foswiki::Meta=HASH(0x9b25c1c)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/Macros/INCLUDE.pm line 296
   Foswiki::__ANON__() called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/CPAN/lib/Error.pm line 379
   eval {...} called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/CPAN/lib/Error.pm line 371
   Error::subs::try('CODE(0x8b2c35c)', 'HASH(0x8b2c04c)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/Macros/INCLUDE.pm line 343
   Foswiki::INCLUDE('Foswiki=HASH(0x9b26a64)', 'Foswiki::Attrs=HASH(0x9ac2d3c)', 'Foswiki::Meta=HASH(0x969118c)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki.pm line 3071
   Foswiki::_expandMacroOnTopicRendering('Foswiki=HASH(0x9b26a64)', 'INCLUDE', '"Main.WebLeftBarExample"', 'Foswiki::Meta=HASH(0x969118c)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki.pm line 2947
   Foswiki::_processMacros('Foswiki=HASH(0x9b26a64)', '%INCLUDE{"Main.WebLeftBarExample"}%', 'CODE(0x8a965bc)', 'Foswiki::Meta=HASH(0x969118c)', 15) called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki.pm line 2965
   Foswiki::_processMacros('Foswiki=HASH(0x9b26a64)', ' %IF{"$raw=\'on\'" then=\'<div class="patternSigLine"><span c...', 'CODE(0x8a965bc)', 'Foswiki::Meta=HASH(0x969118c)', 16) called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki.pm line 2744
   Foswiki::innerExpandMacros('Foswiki=HASH(0x9b26a64)', 'SCALAR(0x96d0a0c)', 'Foswiki::Meta=HASH(0x969118c)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki.pm line 3253
   Foswiki::expandMacros('Foswiki=HASH(0x9b26a64)', ' %IF{"$raw=\'on\'" then=\'<div class="patternSigLine"><span c...', 'Foswiki::Meta=HASH(0x969118c)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/Meta.pm line 3129
   Foswiki::Meta::expandMacros('Foswiki::Meta=HASH(0x969118c)', ' %IF{"$raw=\'on\'" then=\'<div class="patternSigLine"><span c...') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/UI/View.pm line 402
   Foswiki::UI::View::_prepare(' %IF{"$raw=\'on\'" then=\'<div class="patternSigLine"><span c...', 'Foswiki::Meta=HASH(0x969118c)', 0) called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/UI/View.pm line 388
   Foswiki::UI::View::view('Foswiki=HASH(0x9b26a64)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/UI.pm line 316
   Foswiki::UI::__ANON__() called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/CPAN/lib/Error.pm line 379
   eval {...} called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/CPAN/lib/Error.pm line 371
   Error::subs::try('CODE(0x8b2c70c)', 'HASH(0x98a17e4)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/UI.pm line 435
   Foswiki::UI::_execute('Foswiki::Request=HASH(0x9837e3c)', 'CODE(0x8a944f4)', 'view', 1) called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/UI.pm line 274
   Foswiki::UI::handleRequest('Foswiki::Request=HASH(0x9837e3c)') called at /data/www/vhosts/test.foswiki.science.unsw.edu.au/Foswiki/lib/Foswiki/Engine/FastCGI.pm line 137
   Foswiki::Engine::FastCGI::run('Foswiki::Engine::FastCGI=HASH(0x83ff5f4)', undef, 'HASH(0x82fdbc4)') called

-- JayenAshar - 22 Dec 2011

Try this patch:


--- lib/Foswiki/Users/TopicUserMapping.pm       (revision 13546)
+++ lib/Foswiki/Users/TopicUserMapping.pm       (working copy)
@@ -672,7 +672,7 @@
     }
 
     #    print "Returning iterator for eachGroupMember $group \n";
-    return new Foswiki::ListIterator( $this->{eachGroupMember}->{$group} );
+    return new Foswiki::ListIterator( $this->{eachGroupMember}->{$group} || [] );
 }

-- MichaelDaum - 03 Jan 2012

I already rolled back as per Jayen's comment, but I'll try this patch tomorrow and see how it works. Thanks Micha!

-- AaronFuleki - 03 Jan 2012

Hi, I had the same error with 1.1.4 and LdapContrib 4.32 The patch worked for me! Thanks!

-- BertoldAltaner - 09 Jan 2012

Thanks, that patch appears to work for me as well.

-- JayenAshar - 11 Jan 2012

The fix will look a bit different than the above one, and comes in two parts: one in LdapContrib to work around the real bug, and one to fix the real bug.

The real bug is that Foswiki::ListIterator->all() fails when the iterator was created on an undef list. The other iterator methods are robust against such a degenerated list. Not so all(). Instead of segfaulting, it seems sensible behave like iterating over the empty list.

-- MichaelDaum - 11 Jan 2012

i agree completely.

-- SvenDowideit - 12 Jan 2012
 
Topic revision: r17 - 11 Apr 2012, GeorgeClark
 
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. see CopyrightStatement. Creative Commons License