stack-overflow

Stack overflow exception in c# setter

孤街浪徒 提交于 2019-11-28 13:20:13
This is simple to explain: this works using System; using ConstraintSet = System.Collections.Generic.Dictionary<System.String, double>; namespace ConsoleApplication2 { class test { public ConstraintSet a { get; set; } public test() { a = new ConstraintSet(); } static void Main(string[] args) { test abc = new test(); Console.WriteLine("done"); } } } this does not using System; using ConstraintSet = System.Collections.Generic.Dictionary<System.String, double>; namespace ConsoleApplication2 { class test { public ConstraintSet a { get { return a; } set { a = value; } } public test() { a = new

Why do I get a StackOverflowException with my property?

会有一股神秘感。 提交于 2019-11-28 13:04:53
问题 Please explain to me why this code produces a StackOverflowException . There is a mistake in one of the lines as I have shown using comment. I do not however understand why this gives me a StackOverflowException . class TimePeriod { private double seconds; public double hour { get { return hour / 3600; } // should be : get { return seconds / 3600; } set { seconds = value * 3600; } } } class Program { static void Main() { TimePeriod t = new TimePeriod(); t.hour = 5; System.Console.WriteLine(

How do you change default stack size for managed executable.net

折月煮酒 提交于 2019-11-28 12:37:13
We have discovered that one of our auto generated assemblies is throwing a StackOverflowException on new(). This class has (bear with me please) 400+ simple properties that are initialised (most by default(string) etc) in a constructor. We notice that its fine on 64 bits but on 32 bits it goes bang! We need to test if it's reasonable for our use case to create a larger default stack to give us breathing room while we reengineer the code generator. We would esp. interested in solutions that involve app.config if possible. But I'm a realist so anything would be good. Re reasons for the the stack

The difference between t and *t

点点圈 提交于 2019-11-28 11:54:41
问题 package main import "fmt" type TT struct { a int b float32 c string } func (t *TT) String() string { return fmt.Sprintf("%+v", *t) } func main() { tt := &TT{3, 4, "5"} fmt.Printf(tt.String()) } The code can work well. But if I change the String method as in the following, it will cause dead loop. The difference is that the *t is replaced with t . Why? func (t *TT) String() string { return fmt.Sprintf("%+v", t) } 回答1: Because the fmt package checks if the value being printed has a String()

How to ignore property of property in AutoMapper mapping?

时光毁灭记忆、已成空白 提交于 2019-11-28 11:45:13
Image a Person and a Group class with a many-to-many relationship. A person has a list of groups and a group has a list of people. When mapping Person to PersonDTO I have a stack overflow exception because AutoMapper can't handle the Person > Groups > Members > Groups > Members >... So here's the example code: public class Person { public string Name { get; set; } public List<Group> Groups { get; set; } } public class Group { public string Name { get; set; } public List<Person> Members { get; set; } } public class PersonDTO { public string Name { get; set; } public List<GroupDTO> Groups { get;

How to print stack trace of StackOverflowException

只谈情不闲聊 提交于 2019-11-28 11:13:33
I am developing a .Net 2.0 application in which a StackOverflowException occurs. Is there a way to print/log the stack trace before/during the application aborts? This is a long running server-side process which would be hard to execute under a debugger. I know that StackOverflowException can not be caught. Brian Rasmussen Use ADPlus (from Windows Debugging Tools) to force a dump on crash. E.g. adplus -hang -pn <process name> -o <dump file> 来源: https://stackoverflow.com/questions/2591406/how-to-print-stack-trace-of-stackoverflowexception

android parcelable referencing another parcelable circular dependence

痴心易碎 提交于 2019-11-28 10:10:50
Rather simple scenario really, but I could not find anything related on Google so here goes: class ContainerClass implements Parcelable { List<ItemClass> _items; (...) public void writeToParcel( Parcel p, int args ) { p.writeList( _items ); (...) } } class ItemClass implements Parcelable { ContainerClass _containerRef; (...) public void writeToParcel( Parcel p, int args ) { p.writeParcelable( _containerRef ); (...) } } This will inevitably loop and overflow the stack. My question: How am I supposed to deal with a situation where I have to pass an object of the above types through to a new

Android StackOverflow Error

浪子不回头ぞ 提交于 2019-11-28 09:56:03
问题 The following is my stacktrace. I looked through it but it just shows a bunch of views and frankly I'm not too sure what a stackoverflow error is exactly. I read on some of the other questions that some solved theirs through iterations (again, no idea what those are). For the basic layout of the app this is coming from when this crashes is: TabView (5 tabs) > 5th tab > webview in that tab on button press. Now it does actually crash until i hit the back button to go back to the 5th tab and it

Stack Overflow error occurs when using recursive fibonacci function

送分小仙女□ 提交于 2019-11-28 09:48:07
问题 Here's my code and it runs well with values of 400 to 4000 but once it's about 4mil, I get stack overflow errors. Thanks in advance! public class Fib { static int c=1,b=2; static long sum1=0,sum2=0; static long fib(long a){ if(a==1){ return 1; } if(a==2){ return 2; } else{ return fib(a-1)+fib(a-2); } } public static void main(String[] args){ sum2= fib(4000000); System.out.println("Sum %f" +sum2); } } 回答1: Yes - you're running out of stack space. It's far from infinite, and you're using it up

AutoMapper throwing StackOverflowException when calling ProjectTo<T>() on IQueryable

六眼飞鱼酱① 提交于 2019-11-28 09:03:42
I have created classes using EF Code First that have collections of each other. Entities: public class Field { public int Id { get; set; } public string Name { get; set; } public virtual List<AppUser> Teachers { get; set; } public Field() { Teachers = new List<AppUser>(); } } public class AppUser { public int Id { get; set; } public string Email { get; set; } public string Password { get; set; } public string UserName => Email; public virtual List<Field> Fields { get; set; } public AppUser() { Fields = new List<FieldDTO>(); } } DTOs: public class FieldDTO { public int Id { get; set; } public