How to handle or avoid a stack overflow in C++

Handling a stack overflow is not the right solution, instead, you must ensure that your program does not overflow the stack. Do not allocate large variables on the stack (where what is “large” depends on the program). Ensure that any recursive algorithm terminates after a known maximum depth. If a recursive algorithm may recurse an … Read more

What is the difference between a segmentation fault and a stack overflow?

Stack overflow is [a] cause, segmentation fault is the result. At least on x86 and ARM, the “stack” is a piece of memory reserved for placing local variables and return addresses of function calls. When the stack is exhausted, the memory outside of the reserved area will be accessed. But the app did not ask … Read more

What is the use of -fno-stack-protector?

In the standard/stock GCC, stack protector is off by default. However, some Linux distributions have patched GCC to turn it on by default. In my opinion, this is rather harmful, as it breaks the ability to compile anything that’s not linked against the standard userspace libraries unless the Makefile specifically disables stack protector. It would … Read more

How to debug: w3wp.exe process was terminated due to a stack overflow (works on one machine but not another)

This question is a bit old, but I just found a nice way of getting the stack trace of my application just before overflowing and I would like share it with other googlers out there: When your ASP.NET app crashes, a set of debugging files are dumped in a “crash folder” inside this main folder: … Read more

What is and how to fix System.TypeInitializationException error?

Whenever a TypeInitializationException is thrown, check all initialization logic of the type you are referring to for the first time in the statement where the exception is thrown – in your case: Logger. Initialization logic includes: the type’s static constructor (which – if I didn’t miss it – you do not have for Logger) and … Read more

java.lang.StackOverflowError while using a RegEx to Parse big strings

Unfortunately, Java’s builtin regex support has problems with regexes containing repetitive alternative paths (that is, (A|B)*). This is compiled into a recursive call, which results in a StackOverflow error when used on a very large string. A possible solution is to rewrite your regex to not use a repititive alternative, but if your goal is … Read more

How to predict the maximum call depth of a recursive method?

This is clearly JVM- and possibly also architecture-specific. I’ve measured the following: static int i = 0; public static void rec0() { i++; rec0(); } public static void main(String[] args) { … try { i = 0; rec0(); } catch (StackOverflowError e) { System.out.println(i); } … } using Java(TM) SE Runtime Environment (build 1.7.0_09-b05) Java … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)