question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Maximum recursion depth

See original GitHub issue

New Feature Proposal

Description

Add possibility to restrict recursion depth to a maximum number.

Background

We use AngleSharp to parse E-Mails. Those can come from good people and from bad (Spam). In the latter case, the E-Mails often contain invalid tags and invalid HTML. Currently we run into issues with following stuff:

<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">
<div></div><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV=""><D IV="">

And this is only a small piece. The original email is about ten times longer. This one leads to a StackOverflow in CollectionExtensions.GetAllElements<T>(this INode parent, Predicate<T> predicate) while accessing child nodes.

Of course I know that the maximum depth depends on several factors, e.g. from where the code is called and how much is on the stack.

Any other suggestions to solve this issue?

//Edit: maybe we are able to use a iterative solution instead of a recursive one. Are there any reasons for the current choice?

Specification

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:22 (12 by maintainers)

github_iconTop GitHub Comments

1reaction
gabberseppcommented, May 21, 2019

@FlorianRappl please see this gist: https://gist.github.com/gabbersepp/033b5a1fa93f055a8b1d816db5cdcaf3

I have removed all sensible information.

1reaction
gabberseppcommented, May 17, 2019

@FlorianRappl Hey I will send you an example next week.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the maximum recursion depth, and how to increase ...
The recursion limit is usually 1000. – Boris Verkhovskiy. Apr 24, 2019 at 7:29. 4.
Read more >
Python maximum recursion depth exceeded in comparison
The “maximum recursion depth exceeded in comparison” error is raised when you try to execute a function that exceeds Python's built in recursion...
Read more >
Python | Handling recursion limit
When you execute a recursive function in Python on a large input ( > 10^4), you might encounter a “maximum recursion depth exceeded...
Read more >
Get and set the recursion limit in Python (sys.getrecursionlimit ...
Python has the recursion limit, the maximum depth of the Python interpreter stack. If you require deep recursion, you need to set the...
Read more >
recursionerror maximum recursion depth exceeded
The Python "RecursionError: maximum recursion depth exceeded" occurs when a function is being called so many times that the invocations exceed ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found