https://bugs.winehq.org/show_bug.cgi?id=52492
--- Comment #16 from Fabian Maurer dark.shadow4@web.de ---
I modified the patch(conversion from recursive to iterative) and the code seems to work perfectly.
The modification was to remove the list nodes if they're no longer needed which fixes the problem with too much memory usage. You can see the changes I made in the attached patch. Basically adding jobs to the tail of the list and removing nodes which are no longer required.
The conversion to iterative should not fix the issue, it would only turn the stackoverflow into an infinite loop.
Did you do the reverse check, aka that removing your modifications breaks the code again? Because just removing list nodes when they're no longer needed might prevent memory issues, but doesn't fix the infinite loop.
Keep in mind that compiler optimizations might mess with your results.