stack-overflow

Node.js - Maximum call stack size exceeded

会有一股神秘感。 提交于 2019-11-26 04:36:56
问题 When I run my code, Node.js throws a \"RangeError: Maximum call stack size exceeded\" exception caused by too many recursive calls. I tried to increase Node.js stack size by sudo node --stack-size=16000 app , but Node.js crashes without any error message. When I run this again without sudo, then Node.js prints \'Segmentation fault: 11\' . Is there a possibility to solve this without removing my recursive calls? 回答1: You should wrap your recursive function call into a setTimeout , setImmediate

How does a “stack overflow” occur and how do you prevent it?

两盒软妹~` 提交于 2019-11-26 04:35:49
问题 How does a stack overflow occur and what are the best ways to make sure it doesn\'t happen, or ways to prevent one, particularly on web servers, but other examples would be interesting as well? 回答1: Stack A stack, in this context, is the last in, first out buffer you place data while your program runs. Last in, first out (LIFO) means that the last thing you put in is always the first thing you get back out - if you push 2 items on the stack, 'A' and then 'B', then the first thing you pop off

How to change stack size for a .NET program?

一世执手 提交于 2019-11-26 03:58:12
问题 I have a program that does recursive calls for 2 billion times and the stack overflow. I make changes, and then it still need 40K recursive calls. So I need probably several MB stack memory. I heard the stack size is default to 1MB. I tried search online. Some one said to go properties ->linker .........in visual studio, but I cannot find it. Does anybody knows how to increase it? Also I am wondering if I can set it somewhere in my C# program? P.S. I am using 32-bit winXP and 64bit win7. 回答1:

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

前提是你 提交于 2019-11-26 03:58:05
问题 This is my Regex ((?:(?:\'[^\']*\')|[^;])*)[;] It tokenizes a string on semicolons. For example, Hello world; I am having a problem; using regex; Result is three strings Hello world I am having a problem using regex But when I use a large input string I get this error Exception in thread \"main\" java.lang.StackOverflowError at java.util.regex.Pattern$GroupHead.match(Pattern.java:4168) at java.util.regex.Pattern$Loop.match(Pattern.java:4295) at java.util.regex.Pattern$GroupTail.match(Pattern

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

前提是你 提交于 2019-11-26 03:36:14
问题 I decided to try a few experiments to see what I could discover about the size of stack frames, and how far through the stack the currently executing code was. There are two interesting questions we might investigate here: How many levels deep into the stack is the current code? How many levels of recursion can the current method reach before it hits a StackOverflowError ? Stack depth of currently executing code Here\'s the best I could come up with for this: public static int levelsDeep() {

How do I prevent and/or handle a StackOverflowException?

梦想的初衷 提交于 2019-11-26 01:35:56
问题 I would like to either prevent or handle a StackOverflowException that I am getting from a call to the XslCompiledTransform.Transform method within an Xsl Editor I am writing. The problem seems to be that the user can write an Xsl script that is infinitely recursive, and it just blows up on the call to the Transform method. (That is, the problem is not just the typical programmatic error, which is usually the cause of such an exception.) Is there a way to detect and/or limit how many

C# catch a stack overflow exception

邮差的信 提交于 2019-11-26 01:25:00
问题 I have a recursive call to a method that throws a stack overflow exception. The first call is surrounded by a try catch block but the exception is not caught. Does the stack overflow exception behave in a special way? Can I catch/handle the exception properly? Not sure if relevant, but additional information: the exception is not thrown in the main thread the object where the code is throwing the exception is manually loaded by Assembly.LoadFrom(...).CreateInstance(...) 回答1: Starting with 2.0

Java stack overflow error - how to increase the stack size in Eclipse?

大憨熊 提交于 2019-11-26 00:47:57
问题 I am running a program that I\'ve written in Java in Eclipse. The program has a very deep level of recursion for very large inputs. For smaller inputs the program runs fine however when large inputs are given, I get the following error: Exception in thread \"main\" java.lang.StackOverflowError Can this be solved by increasing the Java stack size and if so, how do I do this in Eclipse? Update: @Jon Skeet The code is traversing a parse tree recursively in order to build up a datastructure. So,

Does Python optimize tail recursion?

吃可爱长大的小学妹 提交于 2019-11-25 23:07:39
问题 I have the following piece of code which fails with the following error: RuntimeError: maximum recursion depth exceeded I attempted to rewrite this to allow for tail recursion optimization (TCO). I believe that this code should have been successful if a TCO had taken place. def trisum(n, csum): if n == 0: return csum else: return trisum(n - 1, csum + n) print(trisum(1000, 0)) Should I conclude that Python does not do any type of TCO, or do I just need to define it differently? 回答1: No, and it

How to increase the Java stack size?

孤街浪徒 提交于 2019-11-25 21:59:00
问题 I asked this question to get to know how to increase the runtime call stack size in the JVM. I\'ve got an answer to this, and I\'ve also got many useful answers and comments relevant to how Java handles the situation where a large runtime stack is needed. I\'ve extended my question with the summary of the responses. Originally I wanted to increase the JVM stack size so programs like runs without a StackOverflowError . public class TT { public static long fact(int n) { return n < 2 ? 1 : n *