Summary: Should be able to pause and debug a StackOverflow Exception Test: <script> function a() { f(); } function b() { f(); } function f() { f(); } if (Math.random() < 0.5) a(); else b(); </script> Steps to reproduce: 1. Inspect test page 2. Enable: Pause on All Exceptions 3. Reload the page => Should pause on Stack Overflow Exception => Should be able to ultimately see the start of the stack (`a` or `b`) => Should be able to evaluate in console
Steps: • Improve the performance of pausing with large callstacks - Profile to see where time is spent and address it - We can lazily gather scope information instead of sending it all up front - We can paginate the # of call frames. We don't need to send 1000 up front • When Inspector Debugging is enabled Swizzle the VM's stackLimit with one that has space for debugging frames (say 10kb) - When hitting stack overflow + pausing replace the stackLimit with the original - User should be able to evaluate + debug things to a reasonable degree - When continuing go back to the swizzled stackLimit - When inspector debugger detaches go back to the original stackLimit
<rdar://problem/32887643>
FYI, you should take a look at JSC's Options::softReservedZoneSize() and Options::reservedZoneSize(). Under normal circumstances, JS stack usage is bounded by stack size - reserved zone size. Stack size is determined by the lower of Options::maxPerThreadStackUsage() or system stack size. The reserved zone size (or commonly known in OS parlance as the stack red zone size) is normally set to Options::softReservedZoneSize(). However, when handling an exception (e.g. when creating Error objects), the VM reduces the reserved zone size to Options::reservedZoneSize(). This gives the error code a little more room to play in. The default difference between Options::softReservedZoneSize() and Options::reservedZoneSize() is 64K. In order to not overflow the stack again while handling a StackOverflow, the Inspector code needs to play within this 64K range. Note, not all of the 64K is available to the inspector. The VM and native host code also uses some stack space.