Jacek Caban (@jacek) commented about dlls/vbscript/tests/lang.vbs:
+recursionDepth = 0 +Sub RecurseN(n) + recursionDepth = recursionDepth + 1 + If n > 1 Then RecurseN n - 1 +End Sub +RecurseN 572 +Call ok(recursionDepth = 572, "recursion depth: " & recursionDepth & " expected 572") + +' Error 28: Out of stack space (infinite recursion) +Sub RecurseForever() + RecurseForever +End Sub + +' Error 28: Out of stack space (mutual recursion) +' Depth varies on Windows (572 on Win10 64-bit VM, 1197 on Win10 64-bit CI, +' 3122 on Win10 32-bit CI). The exact limit is not well understood. FWIW, I would expect the exact stack limit to be dependent both on the implementation and on what exactly is on the stack. In jscript, we share the stack between various function calls, so unlike in vbscript, recursive script calls do not use the C stack, only the jscript stack. With that, we can handle overflow in `stack_push`. Ideally, vbscript would do the same, but that is a much larger task, so I am mentioning that just for context.
In the context of this patch, I am fine with your solution, but please avoid documenting such numbers in comments. They are subject to change, so such comments do not age well. Also, let's use some round number in the implementation (like 1024). -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10592#note_136532