stack-overflow

Stack overflow with unique_ptr linked list [closed]

半城伤御伤魂 提交于 2019-11-27 18:25:32
问题 I've converted the following linked list struct struct node { node* next; int v; }; into a c++11 version - that is not using the pointers. struct node { unique_ptr<node> next; int v; }; Adding, removing elements and traversing works fine, however when I insert roughly 1mil elements, I get a stack overflow when when the destructor of the head node is called. I'm not sure what I'm doing wrong. { node n; ... add 10mill elements } <-- crash here 回答1: You are making nothing wrong here. When you

Clojure: Simple factorial causes stack overflow

风格不统一 提交于 2019-11-27 18:01:36
What am I doing wrong? Simple recursion a few thousand calls deep throws a StackOverflowError . If the limit of Clojure recursions is so low, how can I rely on it? (defn fact[x] (if (<= x 1) 1 (* x (fact (- x 1)) ))) user=> (fact 2) 2 user=> (fact 4) 24 user=> (fact 4000) java.lang.StackOverflowError (NO_SOURCE_FILE:0) Siddhartha Reddy The stack size, I understand, depends on the JVM you are using as well as the platform. If you are using the Sun JVM, you can use the -Xss and -XThreadStackSize parameters to set the stack size. The preferred way to do recursion in Clojure though is to use loop

Why does .NET behave so poorly when StackOverflowException is thrown?

泪湿孤枕 提交于 2019-11-27 17:29:40
I'm aware that StackOverflowExceptions in .NET can't be caught, take down their process, and have no stack trace. This is officially documented on MSDN . However, I'm wondering what the technical (or other) reasons are behind the behavior. All MSDN says is: In prior versions of the .NET Framework, your application could catch a StackOverflowException object (for example, to recover from unbounded recursion). However, that practice is currently discouraged because significant additional code is required to reliably catch a stack overflow exception and continue program execution. What is this

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

谁说胖子不能爱 提交于 2019-11-27 17:27:02
The problem I have an ASP.NET 4.0 application that crashes with a stack overflow on one computer, but not another. It runs fine on my development environment. When I move the site to the production server, it throws a stack overflow exception (seen in event log) and the w3wp.exe worker process dies and is replaced with another. What I've tried so far For reference, I used the debug diagnostic tool to try to determine what piece of code is causing the overflow, but I'm not sure how to interpret the output of it. The output is included below. How might an ASP.NET website cause a stack overflow

C# - Entity Framework - An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll

限于喜欢 提交于 2019-11-27 17:15:49
问题 An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll Make sure you do not have an infinite loop or infinite recursion. The below code is called on a success of this method: internal static List<RivWorks.Model.Negotiation.ProductsSold> GetProductsSoldByCompany(Guid CompanyID) { var ret = from a in _dbRiv.ProductsSold where a.Company.CompanyId == CompanyID select a; return ret.ToList(); } On the return it calls into the Entity Model and tries to populate all

java.lang.StackOverflowError when pressing FX ComboBox on Android

大城市里の小女人 提交于 2019-11-27 16:30:56
When using JavaFXPorts on Android (Android 4.1.1 on Asus Transformer Prime TF201 tablet), a java.lang.StackOverflowError is thrown when pressing on a ComboBox (see below the top stacks of the stacktrace). It happens in a ComboBox in my FX application and is also 100% reproducible with the ComboBox example that is in Ensemble. In other words: can't use JavaFX ComboBox. I'm aware of the Android stack size limit posted in many forums and there are various suggestions on what to do when it happens with Android UI and Android APIs. However, can't find a relevant idea to apply when using JavaFX UI

Stack overflow C++

老子叫甜甜 提交于 2019-11-27 16:09:44
This is my code. When I access dtr array in initImg function it gives a stack overflow exception. What might be the reason? #define W 1000 #define H 1000 #define MAX 100000 void initImg(int img[], float dtr[]) { for(int i=0;i<W;i++) for(int j=0;j<H;j++) img[i*W+j]=255; for(int j=0;j<H;j++) { img[j] = 0; img[W*(W-1)+j] = 0; } for(int i=0;i<W;i++) { img[i*W] = 0; img[i*W+H-1] = 0; } for(int i=0;i<W;i++) for(int j=0;j<H;j++) { if(img[i*W+j]==0) dtr[i*W+j] = 0; // <------here else dtr[i*W+j] = MAX; // <------here } } int main() { int image[W*H]; float dtr[W*H]; initImg(image,dtr); return 0; } This

Function parameters max number

安稳与你 提交于 2019-11-27 15:08:17
I did not find any limitation of count function parameters in the C99 standard and I guess it is only limited by stack size. However I've written a simple test program to demonstrate the behavior of a function with a large count of parameters. When its about 10k, I get the following error on gcc (gcc version 4.5.3 on Cygwin): /usr/lib/gcc/i686-pc-cygwin/4.5.3/../../../libcygwin.a(libcmain.o):(.text+0xa9): undefined reference to `_WinMain@16' I realize that such large count of parameters is unlikely but I wonder what parameter of the compiler determines this limit? EDIT script to generate C

StackOverflowError computing factorial of a BigInteger?

纵饮孤独 提交于 2019-11-27 15:03:49
I am trying to write a Java program to calculate factorial of a large number. It seems BigInteger is not able to hold such a large number. The below is the (straightforward) code I wrote. public static BigInteger getFactorial(BigInteger num) { if (num.intValue() == 0) return BigInteger.valueOf(1); if (num.intValue() == 1) return BigInteger.valueOf(1); return num.multiply(getFactorial(num.subtract(BigInteger.valueOf(1)))); } The maximum number the above program handles in 5022, after that the program throws a StackOverflowError . Are there any other ways to handle it? The problem here looks

Using Recursion in C#

随声附和 提交于 2019-11-27 14:56:10
问题 Are there any general rules when using recursion on how to avoid stackoverflows? 回答1: How many times you will be able to recurse will depend on: The stack size (which is usually 1MB IIRC, but the binary can be hand-edited; I wouldn't recommend doing so) How much stack each level of the recursion uses (a method with 10 uncaptured Guid local variables will be take more stack than a method which doesn't have any local variables, for example) The JIT you're using - sometimes the JIT will use tail