stack-overflow

Call asynchronous function recursively

泄露秘密 提交于 2019-11-28 08:11:12
问题 I have an asynchronous function that I want to call multiple times in a row. The problem is that "multiple" can be a few hundred thousand or millions... The obvious way is to call the same function from the callback like that: function foo() { asyncBar(foo); } Of course some logic is involved to stop the recursion. The question is whether the stack is filling with calls and may cause stackoverflow at some point? 回答1: The question is whether the stack is filling with calls and may cause

JSON.NET StackOverflowException while serialization

耗尽温柔 提交于 2019-11-28 06:54:47
问题 My C# program is running into StackOverflowException, when I try to serialize object with similar structure like this: Object has members which reference each other can't be try catched (idk why) if count is set below 6500 (may vary depending on machine) it is successfully serialized Example code below: class Chacha { public Chacha NextChacha { get; set; } } public static readonly JsonSerializerSettings Settings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All,

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

时光总嘲笑我的痴心妄想 提交于 2019-11-28 06:47:47
I have this "learning code" I wrote for the morris seq in f# that suffers from stack overflow that I don't know how to avoid. "morris" returns an infinite sequence of "see and say" sequences (i.e., {{1}, {1,1}, {2,1}, {1,2,1,1}, {1,1,1,2,2,1}, {3,1,2,2,1,1},...}). let printList l = Seq.iter (fun n -> printf "%i" n) l printfn "" let rec morris s = let next str = seq { let cnt = ref 1 // Stack overflow is below when enumerating for cur in [|0|] |> Seq.append str |> Seq.windowed 2 do if cur.[0] <> cur.[1] then yield!( [!cnt ; cur.[0]] ) cnt := 0 incr cnt } seq { yield s yield! morris (next s) //

How can I prevent my Ackerman function from overflowing the stack?

假如想象 提交于 2019-11-28 06:39:09
Is there a way to keep my Ackerman function from creating a stack over flow is does it for relatively small numbers , i.e. (4,2). This is the error {Cannot evaluate expression because the current thread is in a stack overflow state.} private void Button1Click(object sender, EventArgs e) { var t = Ackermann(4,2); label1.Text += string.Format(": {0}", t); label1.Visible = true; } int Ackermann(uint m, uint n) { if (m == 0) return (int) (n+1); if (m > 0 && n == 0) return Ackermann(m - 1, 1); if (m > 0 && n > 0) return Ackermann(m - 1, (uint)Ackermann(m, n - 1)); else { return -1; } } The best way

StackOverflowError when matching large input using RegEx

夙愿已清 提交于 2019-11-28 05:24:40
问题 I got StackOverflowError when matching the result using a RegEx pattern. The pattern is (\d\*?(;(?=\d))?)+ . This regex is used to validate the input: 12345;4342;234*;123*;344324 The input is a string consists of values (only digits) separated by ; . Each value could include one * at the end (used as wildcard for other matching). There is no ; at the end of the string. The problem is that this regex works fine which small number of values. But when the numbers of values is too large (over 300

Why does reduce give a StackOverflowError in Clojure?

微笑、不失礼 提交于 2019-11-28 05:23:39
I'm trying to concatenate a Seq of Seqs. I can do it with apply concat . user=> (count (apply concat (repeat 3000 (repeat 3000 true)))) 9000000 However, from my limited knowledge, I would assume that the use of apply forces the lazy Seq to be realised, and that doesn't seem right for very large inputs. I'd rather do this lazily if I can. So I thought that using reduce would do the job. user=> (count (reduce concat (repeat 3000 (repeat 3000 true)))) But this results in StackOverflowError clojure.lang.RT.seq (RT.java:484) I'm surprised because I would have thought that the semantics of reduce

Android - stackoverflow Error

二次信任 提交于 2019-11-28 04:45:25
问题 Got problem with StackOverflowError. The worse thing that right now its occur only on one device. I've tested so far on: Samsung Galaxy SII (2.3.4) Samsung Nexus S (4.0.3) HTC Wildfire (2.3.7 and 2.2) Samsung Galaxy Tab 10.1 (3.2) ...and everything is fine. But when I send app to customer and He tested it on HTC Holiday 2.3.4 its crash with this error: java.lang.StackOverflowError at android.widget.TextView.onDraw(TextView.java:4329) at android.view.View.draw(View.java:6993) at android.view

how to expand size of Java stack trace to see bottom of stack? (triggering a stack overflow)

可紊 提交于 2019-11-28 03:21:11
问题 In Java, is there any way to view the complete, untruncated stack trace (e.g. by increasing the number of frames recorded), or otherwise get at the bottom of a stack trace? Normally the stack trace is truncated from the top at 1024 frames worth, but for a stack overflow problem this is fairly worthless as you really need to see who made the call that triggered the recursion, down near the bottom. Much better would truncation in the middle of the stack, but evidently Sun's JVM isn't smart

What is the difference between a stack overflow and buffer overflow?

孤街醉人 提交于 2019-11-28 03:01:41
What is different between stack overflow and buffer overflow in Programming ? Stack overflow refers specifically to the case when the execution stack grows beyond the memory that is reserved for it. For example, if you call a function which recursively calls itself without termination, you will cause a stack overflow as each function call creates a new stack frame and the stack will eventually consume more memory than is reserved for it. Buffer overflow refers to any case in which a program writes beyond the end of the memory allocated for any buffer (including on the heap, not just on the

Can/does the (forward) pipe operator prevent tail call optimization?

拈花ヽ惹草 提交于 2019-11-28 02:38:41
问题 For a parameter optimization problem at work I wrote a genetic algorithm to find some good settings because a brute-force solution is unfeasible. Unfortunately, when I return in the morning, most of the time I'm presented with a StackOverflowException . I've been using F# for quite some time now so I'm aware of TCO and the need for functions with accumulator arguments and generally use that form. After a lot of searching I think I was able to nail to the code that triggered the exception: