Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-40154

"Content by label" can render itself recursively, causing a stack overflow

XMLWordPrintable

      NOTE: This bug report is for Confluence Server. Using Confluence Cloud? See the corresponding bug report.

      Summary

      A page with the "Content by label" macro, combined with an Excerpt Display of "Rich content", will render itself leading to a stack overflow.

      This causes:

      • high CPU usage with more than 10MB of log every second.
      • Confluence becomes unresponsive until the overflow finishes.
      • Going to the page can also return an Error page when the page is displayed.
      • The page may render with infinite traces of itself.
      • In Cloud the page will automatically try to refresh every 2 minutes if window is left open and will trigger the problem again.

      Environment

      • Confluence 6.0 or 5.9
      • Content by Label macro

      Steps to Reproduce

      1. Create a new page
      2. Add a "Content by label" macro, configured as:
        • Label: "testing"
        • Excerpt Display: "rich content"
      3. Save the page
      4. Add a label to the page: "testing"
      5. Refresh the page (May require 2 or 3 refreshes for the label to be updated)

      Expected Results

      Page renders quickly and no error are shown in the logs.

      Actual Results

      Log shows many errors:

      2016-01-08 13:19:53.758403500 2016-01-08 13:19:53,749 ERROR [http-bio-1990-exec-4] [xhtml.view.macro.ViewMacroMarshaller] marshalInternal Error rendering macro: contentbylabel
      2016-01-08 13:19:53.758404500  -- url: /wiki/display/TES/KB0001 | page: 3735562 | traceId: 8aa2ccdd327d6df3 | userName: usertest | referer: https://<url>/wiki/pages/editpage.action?pageId=3735562 | action: viewpage
      2016-01-08 13:19:53.758405500 java.lang.StackOverflowError
      2016-01-08 13:19:53.758405500 	at org.antlr.v4.runtime.misc.Array2DHashSet.getOrAdd(Array2DHashSet.java:83)
      2016-01-08 13:19:53.758437500 	at org.antlr.v4.runtime.atn.ATNConfigSet.add(ATNConfigSet.java:167)
      2016-01-08 13:19:53.758437500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1447)
      2016-01-08 13:19:53.758438500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758438500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758446500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758447500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758447500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758452500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758452500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758453500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758453500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758456500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758457500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758457500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758457500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758460500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758461500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758461500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1414)
      2016-01-08 13:19:53.758465500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758465500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758465500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1414)
      2016-01-08 13:19:53.758466500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758469500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758469500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758470500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758470500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1414)
      2016-01-08 13:19:53.758473500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758473500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758479500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758479500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758480500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1414)
      2016-01-08 13:19:53.758480500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758483500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758484500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1414)
      2016-01-08 13:19:53.758484500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758484500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758489500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1414)
      2016-01-08 13:19:53.758490500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758490500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758494500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1414)
      2016-01-08 13:19:53.758494500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758495500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758495500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758498500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758498500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1414)
      2016-01-08 13:19:53.758499500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758499500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758502500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1414)
      2016-01-08 13:19:53.758503500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758506500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758507500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1414)
      2016-01-08 13:19:53.758507500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure_(ParserATNSimulator.java:1492)
      2016-01-08 13:19:53.758508500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closureCheckingStopState(ParserATNSimulator.java:1431)
      2016-01-08 13:19:53.758510500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.closure(ParserATNSimulator.java:1370)
      2016-01-08 13:19:53.758511500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.computeReachSet(ParserATNSimulator.java:884)
      2016-01-08 13:19:53.758511500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.execATNWithFullContext(ParserATNSimulator.java:695)
      2016-01-08 13:19:53.758512500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.execATN(ParserATNSimulator.java:534)
      2016-01-08 13:19:53.758514500 	at org.antlr.v4.runtime.atn.ParserATNSimulator.adaptivePredict(ParserATNSimulator.java:423)
      2016-01-08 13:19:53.758515500 	at com.atlassian.querylang.antlrgen.AqlParser.expr(AqlParser.java:1228)
      2016-01-08 13:19:53.758515500 	at com.atlassian.querylang.antlrgen.AqlParser.subClause(AqlParser.java:1114)
      2016-01-08 13:19:53.758531500 	at com.atlassian.querylang.antlrgen.AqlParser.andClause(AqlParser.java:983)
      2016-01-08 13:19:53.758531500 	at com.atlassian.querylang.antlrgen.AqlParser.orClause(AqlParser.java:915)
      2016-01-08 13:19:53.758532500 	at com.atlassian.querylang.antlrgen.AqlParser.clause(AqlParser.java:864)
      2016-01-08 13:19:53.758532500 	at com.atlassian.querylang.antlrgen.AqlParser.aqlStatement(AqlParser.java:624)
      2016-01-08 13:19:53.758535500 	at com.atlassian.querylang.lib.parserfactory.DefaultParserFactory.createParser(DefaultParserFactory.java:36)
      2016-01-08 13:19:53.758535500 	at com.atlassian.confluence.plugins.cql.impl.DefaultCQLSearchService.createParserForInput(DefaultCQLSearchService.java:339)
      2016-01-08 13:19:53.758536500 	at com.atlassian.confluence.plugins.cql.impl.DefaultCQLSearchService.performV2Search(DefaultCQLSearchService.java:240)
      2016-01-08 13:19:53.758538500 	at com.atlassian.confluence.plugins.cql.impl.DefaultCQLSearchService.searchContent(DefaultCQLSearchService.java:175)
      2016-01-08 13:19:53.758539500 	at com.atlassian.confluence.plugins.cql.impl.DefaultCQLSearchService.searchContent(DefaultCQLSearchService.java:122)
      2016-01-08 13:19:53.758539500 	at com.atlassian.confluence.plugins.macros.advanced.contentbylabel.LabelledContentMacro.makeRenderContext(LabelledContentMacro.java:109)
      2016-01-08 13:19:53.758546500 	at com.atlassian.confluence.plugins.macros.advanced.contentbylabel.LabelledContentMacro.execute(LabelledContentMacro.java:85)
      2016-01-08 13:19:53.758547500 	at com.atlassian.confluence.macro.ContentFilteringMacro.execute(ContentFilteringMacro.java:107)
      2016-01-08 13:19:53.758547500 	at com.atlassian.renderer.v2.macro.ResourceAwareMacroDecorator.execute(ResourceAwareMacroDecorator.java:51)
      2016-01-08 13:19:53.758550500 	at com.atlassian.confluence.macro.V2CompatibilityMacro.execute(V2CompatibilityMacro.java:41)
      2016-01-08 13:19:53.758550500 	at com.atlassian.confluence.macro.LazyLoadingMacroWrapper.execute(LazyLoadingMacroWrapper.java:27)
      truncated to fit comment
      

      On Screen it may show the error: "Oops - an error has occurred" with the following error:

      Cause
      java.lang.RuntimeException: Error rendering template for decorator root
          at com.atlassian.confluence.setup.velocity.ApplyDecoratorDirective.render(ApplyDecoratorDirective.java:183)
      caused by: java.lang.RuntimeException: Error rendering template for decorator page
          at com.atlassian.confluence.setup.velocity.ApplyDecoratorDirective.render(ApplyDecoratorDirective.java:183)
      caused by: org.apache.velocity.exception.MethodInvocationException: Invocation of method 'getDisplayableItems' in class com.atlassian.confluence.plugin.descriptor.web.ConfluenceWebInterfaceManager threw exception net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection at template/includes/menu-macros.vm[line 150, column 45]
          at org.apache.velocity.runtime.parser.node.ASTMethod.handleInvocationException(ASTMethod.java:337)
      caused by: net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection
          at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:201)
      caused by: net.sf.hibernate.HibernateException: collection was evicted
          at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3332)
      Stack Trace:[hide]
      java.lang.RuntimeException: Error rendering template for decorator root
      	at com.atlassian.confluence.setup.velocity.ApplyDecoratorDirective.render(ApplyDecoratorDirective.java:183)
      	at org.apache.velocity.runtime.parser.node.ASTDirective.render(ASTDirective.java:175)
      	at org.apache.velocity.runtime.parser.node.SimpleNode.render(SimpleNode.java:336)
      	at org.apache.velocity.Template.merge(Template.java:328)
      	at org.apache.velocity.Template.merge(Template.java:235)
      	at com.opensymphony.webwork.dispatcher.VelocityResult.doExecute(VelocityResult.java:91)
      	at com.atlassian.xwork.results.ProfiledVelocityResult.doExecute(ProfiledVelocityResult.java:21)
      	at com.atlassian.confluence.setup.webwork.EncodingVelocityResult.doExecute(EncodingVelocityResult.java:48)
      	at com.opensymphony.webwork.dispatcher.WebWorkResultSupport.execute(WebWorkResultSupport.java:116)
      	at com.opensymphony.xwork.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:263)
      	at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:187)
      	at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
      	at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
      	at com.atlassian.confluence.core.ConfluenceWorkflowInterceptor.intercept(ConfluenceWorkflowInterceptor.java:65)
      	at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:165)
      	at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:35)
      truncated to fit.
      

      Notes

      Wasn't happening in Confluence v5.7 and v5.8.10 because the macro didn't have the 'Rich Content' excerpt.
      This is the Macro setting:

      Workaround

      User a different 'Excerpt Display' option in the macro.

      To open the page directly in edit mode:

      1. get the contentid from the database (Cloud customers please contact Cloud Support)
        select *  from content where title like 'Title of the page' and content_status = 'current' and spaceid > 0;
        
      2. use the 'contentid' as the page id value in: https://<confluence-url>/pages/editpage.action?pageId=

              glipatov George Lipatov
              hmurn metrics
              Votes:
              4 Vote for this issue
              Watchers:
              12 Start watching this issue

                Created:
                Updated:
                Resolved: