stack-overflow

Same thread running the same recursive code seems to consume more stack memory in Java 8 compared to Java 7

浪尽此生 提交于 2019-12-01 09:12:23
I am asking a question about "java stack overflow" in the "stackoverflow" site :) A particular thread which makes some recursive function calls for a particular input runs fine in Oracle Java 7 (64 bit) for a configured stack size of 228k (-Xss228k). However, the same thread running the same recursive code for the same input throws a java.lang.StackOverflowError in Oracle Java 8 (64 bit) for the same stack size of 228k. It runs fine in Java 8 if the stack size is increased to 512k (-Xss512k). Any idea why this could happen? Have any changes been made in Java 8 (Hotspot JVM) compared to Java 7

Got stackoverflowerror when using quickSort, can I increase the stack and the heap?

寵の児 提交于 2019-12-01 07:44:19
问题 Can I increase the stack and the heap in java? I'm using BlueJ. ======== EDIT: Here is the code: // ***** Quick-Sort Method ***** public static void quickSort(int[] data, int first, int n) { int p, n1, n2; if(n > 1) { p = partition(data, first, n); n1 = p - first; n2 = n - n1 - 1; quickSort(data, first, n1); quickSort(data, p+1, n2); } } // ***** PRIVATE HELPER FUNCTIONS ***** public static void quickSort(int[] data) { quickSort(data, 0, data.length); } private static int partition(int[] A,

Same thread running the same recursive code seems to consume more stack memory in Java 8 compared to Java 7

倖福魔咒の 提交于 2019-12-01 05:52:32
问题 I am asking a question about "java stack overflow" in the "stackoverflow" site :) A particular thread which makes some recursive function calls for a particular input runs fine in Oracle Java 7 (64 bit) for a configured stack size of 228k (-Xss228k). However, the same thread running the same recursive code for the same input throws a java.lang.StackOverflowError in Oracle Java 8 (64 bit) for the same stack size of 228k. It runs fine in Java 8 if the stack size is increased to 512k (-Xss512k).

-[NSInputStream read:maxLength:] throws an exception saying length is too big, but it isn't

不羁的心 提交于 2019-12-01 05:29:17
I use an NSInputStream to read data from a file. It will crash if maxLength is greater than 49152. When it crashes -- sometimes, but not every time, it gives this message: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSConcreteData initWithBytes:length:copy:freeWhenDone:bytesAreVM:]: absurd length: 4294967295, maximum size: 2147483648 bytes' From my calculation, 524288 is still less than that maximum, and can fit in the return value. What did I miss? - (void)stream:(NSStream *)aStream handleEvent:(NSStreamEvent)eventCode { switch (eventCode) { case

Why are stackoverflow errors chaotic?

北城以北 提交于 2019-12-01 04:43:23
This simple C program rarely terminates at the same call depth: #include <stdio.h> #include <stdlib.h> void recursive(unsigned int rec); int main(void) { recursive(1); return 0; } void recursive(unsigned int rec) { printf("%u\n", rec); recursive(rec + 1); } What could be the reasons behind this chaotic behavior? I am using fedora (16GiB ram, stack size of 8192), and compiled using cc without any options. EDIT I am aware that this program will throw a stackoverflow I know that enabling some compiler optimizations will change the behavior and that the program will reach integer overflow. I am

Preventing StackOverFlow in recursive functions

旧巷老猫 提交于 2019-12-01 03:50:15
I have a recursive function in a BaseClass which relies on a protected virtual function for it's return condition. It's possible for a child class to override this function incorrectly and leads to a StackOverFlow exception. The worst thing is there are some slow network calls and the exception is not gonna happen soon (many resources waste for a long time). I'm looking for a method to check StackOverFlow in early stages some way in the base class (maybe using Reflection and the current recursion level). Any idea ? You could pass a simple integer 'depth' to the recursive function and increment

Why stack overflow causes segmentation fault instead of stack overflow in Linux? [duplicate]

你说的曾经没有我的故事 提交于 2019-12-01 02:47:48
Possible Duplicate: What is the difference between a segmentation fault and a stack overflow? I was just wondering, why stack overflow results in segmentation fault instead of stack overflow. Is it because the boundary of stack limit is crossed which causes SIGSEGV? Why we don't encounter stack overflow in Linux, and rather a segmentation fault? int foo() { return foo(); } This small code should cause stack overflow but rather it causes segmentation fault in Linux. A stack overflow can cause several different kinds of hardware errors. It may lead to an attempt to access memory for which the

How to avoid stack overflow in Haskell?

。_饼干妹妹 提交于 2019-12-01 02:23:11
Haskell does not support cycling for computation, instead it offers to use recursion algorithms. But this approach leads to growing of stack, and even stack overflow. I believe there should be approach to solve this problem in general. Here is the sample. I wanted to know, how many times getClockTime may be called per 5 seconds: import System.Time nSeconds = 5 main = do initTime <- totalPicoSeconds `fmap` getClockTime doWork initTime 1 where doWork initTime n = do currTime <- totalPicoSeconds `fmap` getClockTime if (currTime - initTime) `div` 10 ^ 12 >= nSeconds then print n else doWork

Preventing StackOverFlow in recursive functions

浪尽此生 提交于 2019-12-01 01:49:05
问题 I have a recursive function in a BaseClass which relies on a protected virtual function for it's return condition. It's possible for a child class to override this function incorrectly and leads to a StackOverFlow exception. The worst thing is there are some slow network calls and the exception is not gonna happen soon (many resources waste for a long time). I'm looking for a method to check StackOverFlow in early stages some way in the base class (maybe using Reflection and the current

Windows service / A new guard page for the stack cannot be created

与世无争的帅哥 提交于 2019-11-30 22:40:11
问题 I have a windows service that does some intensive work every one minute (actually it is starting a new thread each time in which it syncs to different systems over http). The problem is, that after a few days it suddenly stops without no error message. I have NLog in place and I have registered for 'AppDomain.CurrentDomain.UnhandledException'. The last entry in the textfile-log is just a normal entry without any problems. Looking in the EventLog, I also can't find any message in the