stack-overflow

Why no segmentation fault on strcpy? [duplicate]

荒凉一梦 提交于 2019-12-02 00:53:55
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Undefined, unspecified and implementation-defined behavior This should seg fault. Why doesn't it. #include <string.h> #include <stdio.h> char str1[] = "Sample string. Sample string. Sample string. Sample string. Sample string. "; char str2[2]; int main () { strcpy (str2,str1); printf("%s\n", str2); return 0; } I am using gcc version 4.4.3 with the following command: gcc -std=c99 testString.c -o test I also tried

Stack smashing code not working on Linux kernel 2.6.38.7… Please help

独自空忆成欢 提交于 2019-12-01 23:55:41
I have been reading "The Shellcoders Handbook" and been referring to this link for practice of stack overflow. But it seems the Linux kernel developers have made the kernel very secure. Here are my problems. 1) This code void function(int a, int b, int c) { char buffer1[8]; char buffer2[10]; int* ret; ret = buffer1 + 6; *ret+=8; } void main() { int x; x = 0; function(1,2,3); x = 1; printf("%d\n",x); } gives the output $ cc smash.c smash.c: In function ‘function’: smash.c:7:8: warning: assignment from incompatible pointer type $ ./a.out 1 but replacing the line *ret+=8 with *ret=8 gives the

Why does my iterative implementation of drop for a linked list still cause a stack overflow?

南笙酒味 提交于 2019-12-01 23:37:14
问题 I am following Learning Rust With Entirely Too Many Linked Lists to write my first program in Rust. I changed the program to: use std::mem; #[derive(Debug)] pub enum List { Nil, More(Box<Node>), } #[derive(Debug)] pub struct Node { val: i32, next: List } impl List { pub fn new() -> Self { List::Nil } pub fn insert(&mut self, v : i32) { let old_head = mem::replace(&mut *self, List::Nil); let new_head = List::More(Box::new(Node { val : v, next: old_head})); *self = new_head } pub fn remove(&mut

JSF: how prevent stackoverflow due to recursion during build phase (despite rendered test)

喜你入骨 提交于 2019-12-01 22:42:17
Apologies for not abstracting this problem in a dedicated test case, I hope the example from a real project is simple enough to describe the problem. I have a JavaEE/JPA2/JSF web application where every @Entity Element (or subclass) has a templated view.xhtml page, and a standard link generator composite component util:view_link.xhtml, invoked as GET with database ID as parameter. A portion (only) of each view page represents an expert system summary; that portion can be abstracted as a composite component, for inclusion in a view page or elsewhere. I have introduced a Primefaces p:dialog

stackoverflow error when creating object outside the main method

女生的网名这么多〃 提交于 2019-12-01 21:27:13
While running this code it shows Stackoverflow error. What is it I am doing wrong, why does the code compile? public class Foo { int a = 5; Foo f = new Foo(); void go() { System.out.println(f.a); } public static void main(String[] args) { Foo f2 = new Foo(); f2.go(); } } You can call go method with an instance only. so before call to go started, c'tor has run for class Foo Now, C'tor is designed to initialize all instance members. So one by one it initializes: a is initialized to 5 f is initialized to an Object // but here is the catch, f never gets initilized. before = operator works, C'tor

What causes “Error C stack overflow” in haskell usually

点点圈 提交于 2019-12-01 20:38:56
问题 What are the usual causes of "Error C stack overflow" in the Hugs Haskell implementation. 回答1: This can come up if you are used to functional languages in which it is common to do tail-recursion factorization. Say you have a function: sum = go 0 where go accum [] = accum go accum (x:xs) = go (accum+x) xs Which, incidentally, is the same as sum = foldl (+) 0 If we evaluate the function we can see the problem: sum [1,2,3,4] go 0 [1,2,3,4] go (0+1) [2,3,4] go ((0+1)+2) [3,4] go (((0+1)+2)+3) [4]

ASP.NET MVC stack overflow exception when calling a partial view from master page

给你一囗甜甜゛ 提交于 2019-12-01 20:26:02
问题 I'm getting a stack overflow error when I try to call a partial view from the master. The Partial View: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %> <form action="/members/TestLoginProcess/" method="post"> U: <input type="text" name="mUsername" /><br /> P: <input type="password" name="mHash" /><br /> <button type="submit">Log In</button> </form> The Action in the "Members" controller [ChildActionOnly] public ActionResult TestLogin() { return PartialView(); } Then I

What causes “Error C stack overflow” in haskell usually

喜你入骨 提交于 2019-12-01 20:10:28
What are the usual causes of "Error C stack overflow" in the Hugs Haskell implementation. This can come up if you are used to functional languages in which it is common to do tail-recursion factorization. Say you have a function: sum = go 0 where go accum [] = accum go accum (x:xs) = go (accum+x) xs Which, incidentally, is the same as sum = foldl (+) 0 If we evaluate the function we can see the problem: sum [1,2,3,4] go 0 [1,2,3,4] go (0+1) [2,3,4] go ((0+1)+2) [3,4] go (((0+1)+2)+3) [4] go ((((0+1)+2)+3)+4) [] (((0+1)+2)+3)+4 Now to evaluate that expression Haskell uses a stack: EXPR | STACK

Why does printing the owner of a closure in a string cause infinite recursion?

时光总嘲笑我的痴心妄想 提交于 2019-12-01 18:24:14
I'm playing with closures and seeing this odd behavior that I can't quite explain: groovy:000> ({ println owner })() groovysh_evaluate@200b6145 ===> null groovy:000> ({ println "${owner}" })() groovysh_evaluate@2bf75a70 ===> null groovy:000> ({ ({ println owner })() })() groovysh_evaluate$_run_closure1@10f67a01 ===> null groovy:000> ({ ({ println "${owner}" })() })() ERROR java.lang.StackOverflowError: null at groovysh_evaluate$_run_closure1_closure2.doCall (groovysh_evaluate:2) at groovysh_evaluate$_run_closure1_closure2.doCall (groovysh_evaluate) at groovysh_evaluate$_run_closure1.doCall

Stack overflow despite tail call position but only in 64-bit

本小妞迷上赌 提交于 2019-12-01 17:50:12
Originated from this question , I have this little F# code ( github ) to generate random values according to a normal distribution: // val nextSingle : (unit -> float32) let nextSingle = let r = System.Random() r.NextDouble >> float32 // val gauss : (float32 -> float32 -> seq<float32>) let gauss mean stdDev = let rec gauss ready = seq { match ready with | Some spare -> yield spare * stdDev + mean yield! gauss None | _ -> let rec loop () = let u = nextSingle() * 2.f - 1.f let v = nextSingle() * 2.f - 1.f let s = pown u 2 + pown v 2 if s >= 1.f || s = 0.f then loop() else u, v, s let u, v, s =