[ http://issues.apache.org/jira/browse/COCOON-1939?page=comments#action_12444507 ] Daniel Fagerstrom commented on COCOON-1939: -------------------------------------------
Thanks for spotting this subtle bug. The call mechanism for inheritance uses a stack. Say that you have an inheritance B->A (A is super block to B). If you call an uri in B, "block:B:/foo", the block context for B will be pushed on the BlockCallStack. Then say that "/foo" isn't defined in block B, in this case it will be called in the super block A instead (the super block is found through the connection map element with the name "super"). But when a super block is called the block context is *not* pushed, so the block context of block B still is on the top of the stack. Say then that while evaluating "/foo", block A do a polymorphic call "block:/bar". Such calls are always done relative the block context on the top of the stack i.e. the context of block B. So "/bar" will first be evaluated in block B and if not foun d there in its super block A. This far everything work as it should even for the case you described above C -> B -> A. Now the problem is that "block:super:/foo" is evaluated relative the top of the call stack. instead of relative the currently called blocks context. This happens to work in the case of inheritance in one step (B->A), as if you call super in the block B, the current block and the block on the call stack is the same: B. But in the case you described above it will not work as B will call its super block relative C rather than it self, and thus get into an infinite loop as you experienced. What needs to be done to solve this problem is to push all called blocks contexts on the stack and mark the super calls in some way. Then a super call should be done relative the top block context, and other (polymorphic) calls should be made relative to the top *non* super call block context. > Stack overflow when inheriting from block that alread inherits from another > one > ------------------------------------------------------------------------------- > > Key: COCOON-1939 > URL: http://issues.apache.org/jira/browse/COCOON-1939 > Project: Cocoon > Issue Type: Bug > Components: - Blocks Framework > Affects Versions: 2.2-dev (Current SVN) > Reporter: Alexander Klimetschek > > There are problems with the following scenario: I have one Block A, another > one B that has A as super-block defined and a third one C that has B as > super-block defined. > The super-relation between B and A works ok, but if you start in C, then > forward to B, which in turn wants to forward to block A (all via the > block:super: protocol), a stack overflow happens. It looks like he always > thinks he is in C, so that block:super: from B will always get to B, thus > creating an endless loop. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira
