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

Re: where is the infinite recurssion? by Jon

Jon
Wed Sep 08 11:21:51 CDT 2004

assaf <assafwo@hotmail.com> wrote:
> 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
>
>
>
>

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Re: where is the infinite recurssion? by Marina

Marina
Wed Sep 08 11:41:22 CDT 2004

The stack trace should say exactly which method caused the exception - it is
probably one of the methods being called in your function.

"assaf" <assafwo@hotmail.com> wrote in message
news:uWFEuOblEHA.396@tk2msftngp13.phx.gbl...
> 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
>
>
>



Re: where is the infinite recurssion? by Bob

Bob
Wed Sep 08 13:46:57 CDT 2004

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






"assaf" <assafwo@hotmail.com> wrote in message
news:uWFEuOblEHA.396@tk2msftngp13.phx.gbl...
> 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
>
>
>



Re: where is the infinite recurssion? by Jon

Jon
Wed Sep 08 13:52:12 CDT 2004

Bob Powell [MVP] <bob@_spamkiller_bobpowell.net> wrote:
> 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.

--
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Re: where is the infinite recurssion? by assaf

assaf
Sun Sep 12 11:17:11 CDT 2004

hi all

so what do u recomend that i do?


assaf


"Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
news:MPG.1ba96533cc86872998b38b@msnews.microsoft.com...
> Bob Powell [MVP] <bob@_spamkiller_bobpowell.net> wrote:
> > 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.
>
> --
> Jon Skeet - <skeet@pobox.com>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too



Re: where is the infinite recurssion? by Alvin

Alvin
Sun Sep 12 11:00:41 CDT 2004

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" <assafwo@hotmail.com> wrote in message
news:OSqwczNmEHA.3428@TK2MSFTNGP14.phx.gbl...
> hi all
>
> so what do u recomend that i do?
>
>
> assaf
>
>
> "Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
> news:MPG.1ba96533cc86872998b38b@msnews.microsoft.com...
>> Bob Powell [MVP] <bob@_spamkiller_bobpowell.net> wrote:
>> > 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.
>>
>> --
>> Jon Skeet - <skeet@pobox.com>
>> http://www.pobox.com/~skeet
>> If replying to the group, please do not mail me too
>
>



Re: where is the infinite recurssion? by assaf

assaf
Mon Sep 13 12:55:09 CDT 2004

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 [MVP]" <vapor at steaming post office> wrote in message
news:#DsWpGOmEHA.1356@TK2MSFTNGP09.phx.gbl...
> 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" <assafwo@hotmail.com> wrote in message
> news:OSqwczNmEHA.3428@TK2MSFTNGP14.phx.gbl...
> > hi all
> >
> > so what do u recomend that i do?
> >
> >
> > assaf
> >
> >
> > "Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
> > news:MPG.1ba96533cc86872998b38b@msnews.microsoft.com...
> >> Bob Powell [MVP] <bob@_spamkiller_bobpowell.net> wrote:
> >> > 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.
> >>
> >> --
> >> Jon Skeet - <skeet@pobox.com>
> >> http://www.pobox.com/~skeet
> >> If replying to the group, please do not mail me too
> >
> >
>
>



Re: where is the infinite recurssion? by Alvin

Alvin
Mon Sep 13 13:03:34 CDT 2004

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" <assafwo@hotmail.com> wrote in message
news:%234iD9PbmEHA.2552@TK2MSFTNGP11.phx.gbl...
> 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 [MVP]" <vapor at steaming post office> wrote in message
> news:#DsWpGOmEHA.1356@TK2MSFTNGP09.phx.gbl...
>> 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" <assafwo@hotmail.com> wrote in message
>> news:OSqwczNmEHA.3428@TK2MSFTNGP14.phx.gbl...
>> > hi all
>> >
>> > so what do u recomend that i do?
>> >
>> >
>> > assaf
>> >
>> >
>> > "Jon Skeet [C# MVP]" <skeet@pobox.com> wrote in message
>> > news:MPG.1ba96533cc86872998b38b@msnews.microsoft.com...
>> >> Bob Powell [MVP] <bob@_spamkiller_bobpowell.net> wrote:
>> >> > 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.
>> >>
>> >> --
>> >> Jon Skeet - <skeet@pobox.com>
>> >> http://www.pobox.com/~skeet
>> >> If replying to the group, please do not mail me too
>> >
>> >
>>
>>
>
>