Re: StackOverflowException with attribute



I figured that the recursion wasn't infinite (but just deep). Since
semantics of methods (like GetProperties) change that could explain
the behaviour (it worked in 1.1 but not in 2.0). Changing the max
recursion depth not only helps to identify the problem in that
particular case but also helps to solve the special case problem. I
used to have these kind of problems all the time...

However, it seems like it's the GetHashCode that makes the thing
infinite so you were right after all.

I can think of a dozen reasons why they opted for using GetHashCode in
2.0 and not in 1.1. After all, the features of the language evolved. I
would make a new implementation of getHashcode and equals.

Cheers,
Stefan.


On May 11, 4:00 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
I don't know what atlaste was trying to indicate by saying to raise the
maximum recursion depth, because in the end, if you have a loop that loops
infinitely, it's always going to be larger than whatever the threshold is.

To me, it would seem that the call to GetProperties on the
TypeDescriptor class is calling back into your GetProperities method, and
it's always going to instantiate another call.

You need to find some way to break this loop. What is it that you are
trying to do?

--
- Nicholas Paldino [.NET/C# MVP]
- m...@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"windsim" <wind...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message

news:2CAF805A-EC2C-41E0-A09A-3979D4B5A3A9@xxxxxxxxxxxxxxxx

Thanks guys!

public PropertyDescriptorCollection GetProperties(Attribute[] attributes)
{
PropertyDescriptorCollection globalizedProps;
PropertyDescriptorCollection baseProps =
TypeDescriptor.GetProperties(this, attributes, true);
...
}
I can not set break point at above code line and I think the problem is
maybe TypeDescriptor.GetProperties(...)

The info from call stack looks like a endless loop below :
...
[External Code]

SystemFrameworks.dll!SystemFrameworks.DataObject.GlobalizedObject.GetProperties(System.Attribute[]
attributes = {Dimensions:[1]}) Line 350 + 0xd bytes C#

SystemFrameworks.dll!SystemFrameworks.DataObject.ModuleProperties.GetStatefulPropertyDescriptors()
Line 92 + 0x26 bytes C#

SystemFrameworks.dll!SystemFrameworks.DataObject.ModuleProperties.GetModulePropertyListCurrent(SystemFrameworks.DataObject.ModuleProperties
mp = {SystemFrameworks.DataObject.DTMProperties}) Line 122 + 0x8 bytes C#

SystemFrameworks.dll!SystemFrameworks.DataObject.ModuleProperties.ToString()
Line 350 + 0xb bytes C#

SystemFrameworks.dll!SystemFrameworks.DataObject.ModuleProperties.GetHashCode()
Line 313 + 0x7 bytes C#
[External Code]

by the way how to increase this max recursion depth in VS 2005?
--
windsim

"Nicholas Paldino [.NET/C# MVP]" wrote:

windsim,

Well, more likely than not you have a recursive call somewhere (or
something that results in an endless loop of calls). Have you set a
breakpoint and looked a the call stack to see where the calls are
repeating
in a loop?

--
- Nicholas Paldino [.NET/C# MVP]
- m...@xxxxxxxxxxxxxxxxxxxxxxxxxxx

"windsim" <wind...@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:ABD92005-416A-4FB2-AB0C-C177F161F535@xxxxxxxxxxxxxxxx
Hi,
I have a project based on .Net 1.1 and VS 2003,now I am trying to
upgrade
it
to .Net 2.0 and VS 2005.The project passes the 'Build Solution',but
When I
start Debug, it suddenly comes StackOverflowException and Debug stops.

The main Exception point is the function below:

public System.ComponentModel.PropertyDescriptorCollection
GetStatefulPropertyDescriptors()
{
DataObject.StatefulPropertyAttribute a = new
StatefulPropertyAttribute();
return this.GetProperties(new Attribute[] { a }); //exception
point
//class System.Attribute that is base class for customer
attributes
}

[AttributeUsage(AttributeTargets.Property, AllowMultiple=false,
Inherited=true)]
public class StatefulPropertyAttribute : Attribute{}

Under .Net 1.1 and VS 2003 there is no problem, no exception for the
function, but why does it come StackOverflowException under .Net 2.0
and
How
to solve it?

--
windsim


.



Relevant Pages

  • Re: Halting Problem
    ... large due to recursion. ... there is a condition for the recursion to terminate. ... they don't have infinite memory. ... All programs without any loop, ...
    (comp.programming)
  • Re: interesting question
    ... infinite, and would run on existing PCs with 8 GBytes of RAM. ... Didn't Dykstra or Hoare prove that any recursion can be performed more ... efficiently with a loop? ... -- Charlie Springer ...
    (comp.lang.forth)
  • Re: Raatikainens critique of Chaitin
    ... dealing with exponential Diophantine equations was ... A subset S of N is bi-immune for a class C if S is infinite but does ... You couldn't have a bi-immunity result for the problem of whether ... Bi-immunity was a concept from the early years of recursion theory, ...
    (sci.math)
  • Re: Response to Karen and to Willem on recursive proofs
    ... >) int nFactorial ... The bits with 'max' are because the loop is a bit ... I agree that this does not need recursion and it is an elegant ... language proofs can be used, and I need to keep the language informal ...
    (comp.programming)
  • Infinite loop in PSOS_INIT()
    ... ARM instruction set simulator) the processor goes into an infinite ... loop at PSOS_INIT. ... We are using ARMulator to simulate a system that has an ARM946ES ...
    (comp.arch.embedded)