Why stack overflow on some machines, but segmentation fault on another?

Why is it I get segmentation faults instead? The segmentation fault, what you’re seeing, is a side-effect of the stack overflow. The reason is stack overflow, the result is segmentation fault. From the wikipedia article for “stack overflow” (emphasis mine) …. When a program attempts to use more space than is available on the call … Read more

Avoiding stack overflow (with F# infinite sequences of sequences)

You should definitely check out http://research.microsoft.com/en-us/um/cambridge/projects/fsharp/manual/FSharp.PowerPack/Microsoft.FSharp.Collections.LazyList.html but I will try to post a more comprehensive answer later. UPDATE Ok, a solution is below. It represents the Morris sequence as a LazyList of LazyLists of int, since I presume you want it to be lazy in ‘both directions’. The F# LazyList (in the FSharp.PowerPack.dll) has three … Read more

Why is the max recursion depth I can reach non-deterministic?

The observed behavior is affected by the HotSpot optimizer, however it is not the only cause. When I run the following code public static void main(String[] argv) { System.out.println(System.getProperty(“java.version”)); System.out.println(countDepth()); System.out.println(countDepth()); System.out.println(countDepth()); System.out.println(countDepth()); System.out.println(countDepth()); System.out.println(countDepth()); System.out.println(countDepth()); } static int countDepth() { try { return 1+countDepth(); } catch(StackOverflowError err) { return 0; } } with JIT … Read more

Large 2D array gives segmentation fault

If your program looks like this … int main(int, char **) { double x[5000][500],y[5000][500],z[5000][500]; // … return 0; } … then you are overflowing the stack. The fastest way to fix this is to add the word static. int main(int, char **) { static double x[5000][500],y[5000][500],z[5000][500]; // … return 0; } The second fastest way … Read more

Why does the count of calls of a recursive method causing a StackOverflowError vary between program runs? [duplicate]

The observed variance is caused by background JIT compilation. This is how the process looks like: Method f() starts execution in interpreter. After a number of invocations (around 250) the method is scheduled for compilation. The compiler thread works in parallel to the application thread. Meanwhile the method continues execution in interpreter. As soon as … Read more

Can a stack overflow result in something other than a segmentation fault?

Yes, even on a standard OS (Linux) and standard hardware (x86). void f(void) { char arr[BIG_NUMBER]; arr[0] = 0; // stack overflow } Note that on x86, the stack grows down, so we are assigning to the beginning of the array to trigger the overflow. The usual disclaimers apply… the exact behavior depends on more … Read more

How to change stack size for a .NET program?

The easiest way to set the stack size from .NET 2.0 and Win XP onwards is to spawn a new thread with the stack size you’d like:- using System.Threading; Thread T = new Thread(threadDelegate, stackSizeInBytes); T.Start(); To change the stack size of the entire program you’d have to use editbin:- EDITBIN.EXE /STACK:<stacksize> file.exe

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