A program can receive a memory error (access violation, bus error, or segmentation fault) when it overflows its stack. It is often necessary to run the program under control of your system's debugger to determine where these errors occur. (However, if the debugger needs to allocate space on the stack, it may not function properly if the stack overflows.)
If a thread receives a memory access exception during a routine call or when accessing a local variable, increase the size of the stack. (To increase the thread's stack size attribute before creating it, call the pthread_attr_stacksize routine. See Section 2.2.3.4 for more information.) However, not all memory access exceptions indicate a stack overflow.
For programs that are not run under a debugger, determining a stack overflow is more difficult. This is especially true if the program continues to run after receiving a memory access exception. For example, if a stack overflow occurs while a mutex is locked, the mutex might not be released as the thread recovers or terminates. When the program attempts to lock that mutex again, it hangs.