Daily iOS
CS fundamentals and algorithms

Recursion and stack limits

You're recursively walking a nested JSON document thousands of levels deep, and it crashes only on a background thread. What's the cause?

How would an interviewer hear this answer? You'll see whether they'd move on, dig in, or say no, and which sentences would trip you up. Your score doesn't change.
See the short answer

Secondary threads get a 512KB stack by default (the main thread gets 1MB), so deep recursion overflows. It crashes the moment frame size × depth exceeds the stack, which is why it passes on main and dies only in the background.

Share a question