ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Weird infinite loop - can anyone help me debug?

September 30, 2008 10:31pm

Subscribe [1]
  • #1 / Sep 30, 2008 10:31pm

    mkornblum

    18 posts

    Howdy folks,

    We are in the late stages of building an EE site and have encountered a weird bug where one particular page triggers an infinite loop somewhere. Apache CPU usage goes to 100% and the page never loads. Enabling full debug mode in Expression Engine gives us this PHP error:

    Fatal error: Allowed memory size of 16777216 bytes exhausted (tried to allocate 12237 bytes) in /blah/blah/blah/system/core/core.template.php on line 735

    The page is nothing special; it has a few embedded templates, and some excerpts from another weblog in it. Most of the pages on our site show about 8MB of PHP memory usage if we turn on template debugging. This one does the same, for the most part, except when it doesn’t. I know that sounds weird, but doing things as simple as adding or removing links in the body of this page can trigger the error (or not trigger it).

    We are not running any extensions.

    We are running the following plugins:
    Character Limiter (v.1.0),
    Magpie RSS Parser (v.1.3.4),
    Randomizer (v.1.0),
    Word Limiter (v.1.0)
    XML Encode (v.1.2)
    Allow EE Code (v.1.2)
    Pages – Crumbs (v.1.1.3)
    Pages – Nested Menu (v.1.1.9)

    I think the only one of those being used on this page is the Word Limiter.

    I can also post the body of the template in question, if that helps. I don’t think there are any security risks in doing so?

    Thanks in advance!

    Mark

  • #2 / Sep 30, 2008 11:04pm

    Greg Aker

    6022 posts

    Mark:

    Sorry you’re having these problems.  Seeing some code would be helpful, as well as a link to your site.

    What version AND build are you running—You can find this in the footer of your control panel.

    Thanks,

    -greg

  • #3 / Oct 01, 2008 3:24pm

    mkornblum

    18 posts

    We are running 1.6.4, build 20080808.

    Here’s the template in question:

    {assign_variable:my_template_group="my_template_group"}
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html >
        {exp:weblog:entries weblog="default_site"}
        {embed="{my_template_group}/.head" title="{title}"}
        
        <body>
    
        {embed="{my_template_group}/.header"}
        
           {if logged_in}
            {embed="{my_template_group}/.admin" weblog_id="{weblog_id}" entry_id="{entry_id}"}
           {/if}    
    
        {related_entries id="nav_menu"}
            {embed="{my_template_group}/.navigation" menu_body ='{menu_body}'}
        {/related_entries}
    
        {if sidebar}
        <div id="Content-3Col">
        {if:else}
        <div id="Content-2Col">
        {/if}
    
    {if segment_2}
    
    <a href="http://{homepage}">Home</a>
    {exp:pages_crumbs}
     »     <a href="http://{pc_page_url}" title="{pc_title}">{pc_title}</a>
    {/exp:pages_crumbs}
     
    {/if}
    
            <h1>{title}</h1>
    
    {exp:allow_eecode}
    {body}
    {/exp:allow_eecode}
        
        </div>
    
        {if sidebar}
            <div id="RightCol"><div id="RightCol-Lower">{sidebar}</div></div>
        {/if}
    
        {embed="{my_template_group}/.footer"}
        </body>
    {/exp:weblog:entries}
    </html>

    The page body in question is:

    <div id="AudienceNav">
        <a href="https://webmail.cornish.edu/class=IconEmail">Check Email</a>
        <a href="/library/class=IconLibrary">Library</a>
        <a href="/campus/cafe/class=IconCafe">Cafe Menu</a>
        <a href="http://go.arts.cornish.edu/class=IconInfoPortal">Info Portal</a>
        <a href="/faculty/forms/class=IconForms">HR Forms</a>
        <a href="http://arts.cornish.edu/registrar/academic-calendar/class=IconAcCalendar">Academic Calendar</a>
    </div>
    
    <h2>Recent News</h2>
    
    <p>{exp:weblog:entries  weblog="cornish_news" dynamic="off" orderby="date"  limit="3" disable="categories|category_fields|member_data|pagination|trackbacks"}<br />
            </p><h4>{title}</h4><p>  <br />
            {exp:word_limit total="40"}{news_body}{/exp:word_limit}<br />
            <a href="http://{title_permalink=">Read More »</a><br />
    {/exp:weblog:entries}


    It’s probably worth mentioning that literally this exact same template works fine on other pages on our site; it’s only this one page that it seems to have problems with. Even there, if we remove one of the 6 links in the page body, everything is fine. With 6, infinite loop and out of memory error. As I said, very weird.

    Thanks for any help!

    Mark

  • #4 / Oct 01, 2008 8:02pm

    Greg Aker

    6022 posts

    Humm.

    I wonder if the culprit could be from an entry with EE Code.  Do you have an example of “EE” code you are running in your entries?  If you were to “close” the status of an entry with EE code in it, do you see a difference?

    -greg

  • #5 / Oct 01, 2008 8:50pm

    mkornblum

    18 posts

    As far as I know, there isn’t any EE code in any of the entries. I will double check, but the entries are just news posts we imported from Moveable Type.

    The second piece of code above (what I referred to as the “page body in question”) is being shown in the template above. We are using the Pages module to control most of the site. What we are trying to do here is have a Page (in the Pages Module sense) located at “www.domain.edu/faculty/”, and the body of that Page contains some EE code that pulls entries in from our News blog.

    Thanks for your help!

    Mark

  • #6 / Oct 02, 2008 11:44am

    Robin Sowell

    13255 posts

    I’m not loving everything being inside a weblog tag on that initial page.  Can you put a limit=“1” on it?  From looking at it, should only ever return one entry or you get multiple headers and such.  But the limit should eliminate the possibility.  I’d also disable whatever is possible.

    And since the error seems triggered when you edit/save some things, I’m wondering if it’s NOT triggered every time due to caching.  Can you turn all caching off- template, in ‘Admin- System Prefs- DB Settings’ and in the ‘Admin- Weblog Admin- Weblog Management’ prefs.  Is the error consistently triggered then?

    If so, I suspect some reduction testing will be the next step.  But it will help if the error is consistent.  Or if the limit 1 makes it go away 😉.

  • #7 / Oct 02, 2008 5:16pm

    mkornblum

    18 posts

    OK, so I added limit=“1” and no change in the behavior, although since we are using Pages pretty heavily I think that’s a good parameter to have in there regardless 😉

    All caching is off, no change.

    Other things I tried:

    Removing the weblog tag in the “body” (page loads fine, but we want to show recent news posts!), removing the word limit tag from body (no change, still crashes), changing the limit on weblog tag in the body (no change), removing the “crumbs” plugin code from the template (no change), adding “dynamic=off” to the outer template (shows the wrong page then)

    I also just noticed I had a typo in my “page body” code above, it should read:

    <div id="AudienceNav">
        <a href="https://webmail.cornish.edu/class=IconEmail">Check Email</a>
        <a href="/library/class=IconLibrary">Library</a>
        <a href="/campus/cafe/class=IconCafe">Cafe Menu</a>
        <a href="http://go.arts.cornish.edu/class=IconInfoPortal">Info Portal</a>
        <a href="/faculty/forms/class=IconForms">HR Forms</a>
        <a href="http://arts.cornish.edu/registrar/academic-calendar/class=IconAcCalendar">Academic Calendar</a>
    </div>
    
    <h2>Recent News</h2>
    
    <p>{exp:weblog:entries  weblog="cornish_news" dynamic="off" orderby="date"  limit="4" disable="categories|category_fields|member_data|pagination|trackbacks"}<br />
            </p><h4>{title}</h4><p>  <br />
            {exp:word_limit total="40"}{news_body}{/exp:word_limit}<br />
            <a href="http://{title_permalink=">Read More »</a><br />
    {/exp:weblog:entries}

    Thanks for all your help! If you need me to post any of the SQL report or anything, I have full debugging turned on right now, so I can do that.

  • #8 / Oct 05, 2008 1:27pm

    Lisa Wess

    20502 posts

    mkornblum - You have a lot of embeds going on there.  The way I would suggest you test this is to set up a test template with, say, only one weblog entries tag and check it.  See if the problem occurs.  If not- very slowly add code snippets until you find the problem.

    Once you find it, we can help identify why it’s a problem.  Unfortunately, this type of isolation and reduction testing is going to be necessary in this case.

  • #9 / Oct 06, 2008 4:42pm

    mkornblum

    18 posts

    OK, I got the template stripped of all embeds, and I’m still getting the same error with that page body. The template is now:

    {assign_variable:my_template_group="cornish2006"}
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html >
        {exp:weblog:entries weblog="default_site" limit="1"}
        
        <body>
    
            <h1>{title}</h1>
    
    {exp:allow_eecode}
    {body}
    {/exp:allow_eecode}
        
        </div>
    
        </body>
    {/exp:weblog:entries}
    </html>


    And the page body is still:

    <div id="AudienceNav">
        <a href="https://webmail.cornish.edu/class=IconEmail">Check Email</a>
        <a href="/library/class=IconLibrary">Library</a>
        <a href="/campus/cafe/class=IconCafe">Cafe Menu</a>
        <a href="http://go.arts.cornish.edu/class=IconInfoPortal">Info Portal</a>
        <a href="/faculty/forms/class=IconForms">HR Forms</a>
        <a href="http://arts.cornish.edu/registrar/academic-calendar/class=IconAcCalendar">Academic Calendar</a>
    </div>
    
    <h2>Recent News</h2>
    
    <p>{exp:weblog:entries  weblog="cornish_news" dynamic="off" orderby="date"  limit="4" disable="categories|category_fields|member_data|pagination|trackbacks"}<br />
            </p><h4>{title}</h4><p>  <br />
            {exp:word_limit total="40"}{news_body}{/exp:word_limit}<br />
            <a href="http://{title_permalink=">Read More »</a><br />
    {/exp:weblog:entries}

    Note that I do not think this error is pages-module related, because I get the same infinite loop if I access this post using the domain.edu/templateGroup/template/postURL format as I do if I access it through its Pages URL.

    Thanks!

  • #10 / Oct 06, 2008 4:49pm

    Lisa Wess

    20502 posts

    Need more reduction testing still.  Can you try this:

    {exp:weblog:entries weblog="default_site" limit="1"}
        
    
            <h1>{title}</h1>
    
    
    {body}
    
        
       
    {/exp:weblog:entries}

    and see if you’re still getting the loop?

  • #11 / Oct 06, 2008 4:52pm

    mkornblum

    18 posts

    Yes, still occurring with that code. I am 99% certain it’s something to do with that particular post body, although I have no idea what could be causing it.

  • #12 / Oct 06, 2008 4:57pm

    Lisa Wess

    20502 posts

    Er, ok.  So when you have a totally blank template with *just* the code I posted above - you get a huge memory error?

    What if you put in your blank template just “Hello World”?

    This seems really, really familiar.  What version of PHP and MySQL are you on?

    Also, can you try updating to the latest build and see if that helps, please?

  • #13 / Oct 06, 2008 5:34pm

    mkornblum

    18 posts

    Putting just “Hello World” in the template displays fine, no loop.

    Updated to latest EE build (20080829), still get the memory error even when using only the template you posted.

    To clarify my last post, if I access the template you posted through the regular Expression Engine url method (ie, domain.edu/templateGroup/templateName) it displays fine. However, it is not displaying the post body in question, since that’s not the most recent post to our site.

    If I try to access the post body in question, whether though pages (domain.edu/faculty/) or through the regular EE method (domain.edu/templateGroup/templateName/articleURL) I get the out of memory error.

  • #14 / Oct 06, 2008 5:38pm

    Lisa Wess

    20502 posts

    And you get that with only this entry, not with any other entry?  If you create another entry that has the same content and visit that - does the same problem occur?

    What are the contents of that entry?

  • #15 / Oct 06, 2008 6:41pm

    mkornblum

    18 posts

    It is only that one entry, and the same problem does occur if I put the same content into another entry and then visit that one. Believe it or not, if I remove one of the anchors from the first div it displays fine. The same is true if I add one, to make 7 anchors.

    The entry is thus:

    <div id="AudienceNav"> 
        <a href="https://webmail.cornish.edu/class=IconEmail">Check Email</a>
        <a href="/library/class=IconLibrary">Library</a>
        <a href="/campus/cafe/class=IconCafe">Cafe Menu</a>
        <a href="http://go.arts.cornish.edu/class=IconInfoPortal">Info Portal</a>
        <a href="/faculty/forms/class=IconForms">HR Forms</a>
        <a href="http://arts.cornish.edu/registrar/academic-calendar/class=IconAcCalendar">Academic Calendar</a>
    </div>
    
    <h2>Recent News</h2>
    
    <p>{exp:weblog:entries  weblog="cornish_news" dynamic="off" orderby="date"  limit="4" disable="categories|category_fields|member_data|pagination|trackbacks"}<br />
            </p><h4>{title}</h4><p>  <br />
            {exp:word_limit total="40"}{news_body}{/exp:word_limit}<br />
            <a href="http://{title_permalink=">Read More »</a><br />
    {/exp:weblog:entries}

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases