stack-overflow

How can I guarantee catching a EXCEPTION_STACK_OVERFLOW structured exception in C++ under Visual Studio 2005?

让人想犯罪 __ 提交于 2019-12-04 11:58:31
问题 Background I have an application with a Poof-Crash [ 1 ]. I'm fairly certain it is due to a blown stack. The application is Multi-Threaded. I am compiling with " Enable C++ Exceptions: Yes With SEH Exceptions (/EHa) ". I have written an SE Translator function and called _set_se_translator() with it. I have written functions for and setup set_terminate() and set_unexpected() . To get the Stack Overflow, I must run in release mode, under heavy load, for several days. Running under a debugger is

Why does compiling this code cause a compiler stack overflow?

£可爱£侵袭症+ 提交于 2019-12-04 10:54:43
问题 interface Pong<T> {} class Ping<T> implements Pong<Pong<? super Ping<Ping<T>>>> { static void Ping() { Pong<? super Ping<Long>> Ping = new Ping<Long>(); } } Trying to compile this gives the error: The system is out of resources. Consult the following stack trace for details. java.lang.StackOverflowError at com.sun.tools.javac.code.Types$23.visitClassType(Types.java:2579) at com.sun.tools.javac.code.Type$ClassType.accept(Type.java:554) at com.sun.tools.javac.code.Types$UnaryVisitor.visit(Types

Tail recursion issue

时光毁灭记忆、已成空白 提交于 2019-12-04 10:41:14
We were experimenting with parallel collections in Scala and wanted to check whether the result was ordered. For that, I wrote a small function on the REPL to do that check on the very large List we were producing: def isOrdered(l:List[Int]):Boolean = { l match { case Nil => true case x::Nil => true case x::y::Nil => x>y case x::y::tail => x>y & isOrdered(tail) } } It fails with a stackOverflow (how appropriate for a question here!). I was expecting it to be tail-optimized. What's wrong? isOrdered is not the last call in your code, the & operator is. Try this instead: @scala.annotation.tailrec

Arithmetic operation resulted in an overflow in unsafe C#

纵然是瞬间 提交于 2019-12-04 10:26:29
Background We've been using some code copied verbatim from Joe Duffy's "Concurrent Programming on Windows" (page 149) in production for over a year. The code (below) is used in our Asp.Net web application to probe if there's enough stack space. Our site allows users to script out their own web pages and control logic in a simple proprietry scripting language - it's possible for a user to script something nasty and cause a stackoverflow exception, so we use Duffy's code example to stop execution of the errant script before the uncatchable StackOverflow exception takes down the whole IIS AppPool

“Recursive on All Control Paths” error when implementing factorial function

我的未来我决定 提交于 2019-12-04 10:25:16
For class I have an assignment: Write a C++ program that will output the number of distinct ways in which you can pick k objects out of a set of n objects (both n and k should be positive integers). This number is given by the following formula: C(n, k) = n!/(k! * (n - k)!) Your program should use two value-returning functions. The first one should be called factorial and should return n! . The second function should be called combinations and should return n!/(k! * (n - k)!). Test your program for different values of n and k five times (count-controlled loop). I came up with a solution:

“Normal” UIButton causing obj_stack_overflow or EXC_BAD_ACCESS exception

孤街浪徒 提交于 2019-12-04 10:16:11
It sure looks innocuous enough. In my App Delegate, I check NSUserDefaults for a flag to show tips at startup. If it’s set then, at the end of applicationDidFinishLaunching: , I do this: TipsViewController *vc = [[TipsViewController alloc] initWithNibName:@“TipsView" bundle:nil]; [window addSubview:vc.view]; [vc release]; The idea is to show this view temporarily. (Note that it’s not a modal VC. No Navigation Controller at this point, plus there’s no navigation bar in this view anyway.) Once this view is dismissed, we’ll add our pre-empted UITabBarController ’s view to the window and

Scala recursion vs loop: performance and runtime considerations

白昼怎懂夜的黑 提交于 2019-12-04 09:36:09
问题 I've wrote a naïve test-bed to measure the performance of three kinds of factorial implementation: loop based, non tail-recursive and tail-recursive. Surprisingly to me the worst performant was the loop ones («while» was expected to be more efficient so I provided both) that cost almost twice than the tail recursive alternative. ANSWER: fixing the loop implementation avoiding the *= operator wich outperform worst with BigInt due to its internals «loops» became fastest as expected Another

Attempting to use continuation passing style to avoid stack overflow with minimax algorithm

大城市里の小女人 提交于 2019-12-04 09:08:06
Summary of my objective: Figure out how to use continuation-passing style to avoid a stack overflow when using an algorithm I believe cannot be made tail-recursive. Alternatively, find a way to make the function tail-recursive. Details: I am new to F# (and functional programming in general) and I am attempting to implement the minimax algorithm with alpha-beta pruning. This is an algorithm used to determine the best possible move for a two-player game. The pseudocode for the algorithm can be found here: https://en.wikipedia.org/wiki/Alpha%E2%80%93beta_pruning This is a resource I've found

How come Go doesn't have stackoverflows

笑着哭i 提交于 2019-12-04 07:58:35
问题 I read in this presentation http://golang.org/doc/ExpressivenessOfGo.pdf page 42: Safe - no stack overflows How is this possible? and/or how does Go works to avoid this? 回答1: It's a feature called "segmented stacks": every goroutine has its own stack, allocated on the heap. In the simplest case, programming language implementations use a single stack per process/address space, commonly managed with special processor instructions called push and pop (or something like that) and implemented as

Is there a workaround for “stack level too deep” errors in recursive routines?

南楼画角 提交于 2019-12-04 07:55:11
Is there any workaround for Stack Overflow errors in recursive functions in Ruby? Say, for example, I have this block: def countUpTo(current, final) puts current return nil if current == final countUpTo(current+1, final) end if I call countUpTo(1, 10000) , I get an error: stack level too deep (SystemStackError) . It appears to break at 8187. Is there some function that I can call telling Ruby to ignore the size of stacks, or a way to increase the maximum stack size? Andrew Grimm If you're using YARV (the C based implementation of Ruby 1.9), you can tell the Ruby VM to turn tail call