Skip to content

Fix stack overflow in MethodAttr#documented? on cyclic includes - #1829

Open
SulimanAbdulrazzaq wants to merge 1 commit into
ruby:masterfrom
SulimanAbdulrazzaq:fix/cyclic-see-documented
Open

SulimanAbdulrazzaq wants to merge 1 commit into
ruby:masterfrom
SulimanAbdulrazzaq:fix/cyclic-see-documented

Conversation

@SulimanAbdulrazzaq

Copy link
Copy Markdown

MethodAttr#documented? also treats a method as documented when its alias or its #see method is documented, and #see is looked up in the ancestors of the method's owner. With the reproduction from #1088 (comment) (two modules that include each other), A#m.see is B#m and B#m.see is A#m, so documented? recursed until rdoc stopped with "stack level too deep". A superclass cycle, which #1785 made ancestors handle, ends in the same loop.

The guard stays inside documented?: a method or attribute that is reached again while it is still being checked counts as undocumented, since the cycle adds no documentation, and every other alias and #see path is still followed. The flag is only set around the check and is reset in an ensure, so a later call gives the same answer.

The new tests in method_attr_test.rb cover cyclic includes with and without a documented method, and a superclass cycle.

Fixes #1088

MethodAttr#documented? also consults the alias and the #see method,
and #see is looked up in the ancestors of the method's owner.  When
the parsed code has modules that include each other (or a superclass
cycle), A#m.see is B#m and B#m.see is A#m, so documented? recursed
until rdoc stopped with "stack level too deep".

Treat a method/attribute that is reached again while it is already
being checked as undocumented: the cycle adds no documentation, and
every other alias or #see path is still followed.

Fixes ruby#1088
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Including modules creates an infinite loop between methods

1 participant