where is the infinite recurssion?

  • Thread starter Thread starter assaf
  • Start date Start date
A

assaf

hi all

this is the original dot net Region.GetRegionScans.

i am experiencing StackOverflowException when i call it with a
many-rectangle region.

i am looking for the recurssion,
but i can't find it...

can u?


public RectangleF[] GetRegionScans(Matrix matrix)
{
int num4;
GPRECTF gprectf1;
if (matrix == null)
{
throw new ArgumentNullException("matrix");
}
int num1 = 0;
int num2 = SafeNativeMethods.GdipGetRegionScansCount(new
HandleRef(this, this.nativeRegion), out num1, new HandleRef(matrix,
matrix.nativeMatrix));
if (num2 != 0)
{
throw SafeNativeMethods.StatusException(num2);
}
int num3 = Marshal.SizeOf(typeof(GPRECTF));
IntPtr ptr1 = Marshal.AllocHGlobal(((int) (num3 * num1)));
num2 = SafeNativeMethods.GdipGetRegionScans(new HandleRef(this,
this.nativeRegion), ptr1, out num1, new HandleRef(matrix,
matrix.nativeMatrix));
if (num2 != 0)
{
Marshal.FreeHGlobal(ptr1);
throw SafeNativeMethods.StatusException(num2);
}
gprectf1 = new GPRECTF();
RectangleF[] efArray1 = new RectangleF[num1];
for (num4 = 0; (num4 < num1); ++num4)
{
gprectf1 = ((GPRECTF)
UnsafeNativeMethods.PtrToStructure(((IntPtr) (((long) ptr1) + (num3 *
num4))), typeof(GPRECTF)));
efArray1[num4] = gprectf1.ToRectangleF();
}
return efArray1;
}


assaf
 
assaf said:
this is the original dot net Region.GetRegionScans.

i am experiencing StackOverflowException when i call it with a
many-rectangle region.

i am looking for the recurssion,
but i can't find it...

can u?

Well, it's calling other methods such as
SafeNativeMethods.GdipGetRegionScans - it could be that that's what's
eating up the stack.
public RectangleF[] GetRegionScans(Matrix matrix)
{
int num4;
GPRECTF gprectf1;
if (matrix == null)
{
throw new ArgumentNullException("matrix");
}
int num1 = 0;
int num2 = SafeNativeMethods.GdipGetRegionScansCount(new
HandleRef(this, this.nativeRegion), out num1, new HandleRef(matrix,
matrix.nativeMatrix));
if (num2 != 0)
{
throw SafeNativeMethods.StatusException(num2);
}
int num3 = Marshal.SizeOf(typeof(GPRECTF));
IntPtr ptr1 = Marshal.AllocHGlobal(((int) (num3 * num1)));
num2 = SafeNativeMethods.GdipGetRegionScans(new HandleRef(this,
this.nativeRegion), ptr1, out num1, new HandleRef(matrix,
matrix.nativeMatrix));
if (num2 != 0)
{
Marshal.FreeHGlobal(ptr1);
throw SafeNativeMethods.StatusException(num2);
}
gprectf1 = new GPRECTF();
RectangleF[] efArray1 = new RectangleF[num1];
for (num4 = 0; (num4 < num1); ++num4)
{
gprectf1 = ((GPRECTF)
UnsafeNativeMethods.PtrToStructure(((IntPtr) (((long) ptr1) + (num3 *
num4))), typeof(GPRECTF)));
efArray1[num4] = gprectf1.ToRectangleF();
}
return efArray1;
}


assaf
 
The stack trace should say exactly which method caused the exception - it is
probably one of the methods being called in your function.
 
GetRegionScans has a known bug that includes an unmanaged memory leak. This
makes it virtually unusable.

Testing on the beta version of .NET shows that this has been fixed. I have
yet to test whether it's still in the framework 1.1 service-pack.

The GDI+ FAQ has an article on the GetRegionScans bug.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

The GDI+ FAQ RSS feed: http://www.bobpowell.net/faqfeed.xml
Windows Forms Tips and Tricks RSS: http://www.bobpowell.net/tipstricks.xml
Bob's Blog: http://bobpowelldotnet.blogspot.com/atom.xml
 
Bob Powell said:
GetRegionScans has a known bug that includes an unmanaged memory leak. This
makes it virtually unusable.

Testing on the beta version of .NET shows that this has been fixed. I have
yet to test whether it's still in the framework 1.1 service-pack.

The code given before crashes on my box which has 1.1 SP1 on, so yes, I
think the bug's still there.
 
hi alvin

i am an experienced developer.
(but not an mvp)
i dont' understand what u mean.
could u perhaps give me 1 or 2 more clues?

plz


assaf



Alvin Bruney said:
why don't you set visual studio (if that is your IDE) to attach the debugger
when an exception occurs. that way you will know exactly which line popped
the stack instead of guessing. (CTRL+ALT+E) set your options appropriately
 
if you are using visual studio .net you can set the debugger to break on the
line of code which first throws the exception. so if you have an exception
being thrown you can point to the exact line causing the problem. Hopefully,
it is the region method but it may not necessarily be. to eliminate that you
should set your debugger appropriately by pressing CTRL+ALT+E, select break
into the debugger radio button and click ok. run the application and see
what gives. remember to reset this radio button back to continue. the effect
of this is to confirm exactly where the error is.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
assaf said:
hi alvin

i am an experienced developer.
(but not an mvp)
i dont' understand what u mean.
could u perhaps give me 1 or 2 more clues?

plz


assaf



Alvin Bruney said:
why don't you set visual studio (if that is your IDE) to attach the debugger
when an exception occurs. that way you will know exactly which line
popped
the stack instead of guessing. (CTRL+ALT+E) set your options
appropriately

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
assaf said:
hi all

so what do u recomend that i do?


assaf


GetRegionScans has a known bug that includes an unmanaged memory leak.
This
makes it virtually unusable.

Testing on the beta version of .NET shows that this has been fixed.
I
have
yet to test whether it's still in the framework 1.1 service-pack.

The code given before crashes on my box which has 1.1 SP1 on, so yes,
I
think the bug's still there.
 
Back
Top