RunUO Community

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Really weird error with Ultima SDK

K

KevinEvans

Guest
Really weird error with Ultima SDK

I was playing with Ultima SDK today and I got this really weird error:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

I've never had it before, so I have no idea how to solve it. Here's the full error:
Code:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Drawing.SafeNativeMethods.Gdip.IntGdipDisposeImage(HandleRef image)
   at System.Drawing.SafeNativeMethods.Gdip.GdipDisposeImage(HandleRef image)
   at System.Drawing.Image.Dispose(Boolean disposing)
   at System.Drawing.Image.Finalize()

Has anyone seen this before? and know how to solve it?
 

Jeff

Lord
KevinEvans;845528 said:
I was playing with Ultima SDK today and I got this really weird error:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

I've never had it before, so I have no idea how to solve it. Here's the full error:
Code:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Drawing.SafeNativeMethods.Gdip.IntGdipDisposeImage(HandleRef image)
   at System.Drawing.SafeNativeMethods.Gdip.GdipDisposeImage(HandleRef image)
   at System.Drawing.Image.Dispose(Boolean disposing)
   at System.Drawing.Image.Finalize()

Has anyone seen this before? and know how to solve it?

Can you perhaps tell us what function was called when this happened? This is generally an issue with possibly disposed items/memory.
 

Jeff

Lord
KevinEvans;845548 said:
I believe that it was in Animations.GetAnimation()

Ah, from what I remember, this method uses Unsafe stuff, and in doing this, you can unintentionally read past the length of the stream since it uses pointers... This could very easily create the error mentioned.
 
K

KevinEvans

Guest
Oh, hurm.
I guess it's not a really big deal (since it rarely happens).
 

Jeff

Lord
KevinEvans;845552 said:
Oh, hurm.
I guess it's not a really big deal (since it rarely happens).

It probably means you went to an animation that doesnt exist... those numbers are used to generate a read position in the anim.mul file, and if the numbers calculate something invalid...error :)
 
K

KevinEvans

Guest
Is there anyway that I could catch the error beforehand?
All I know is it's being caused by:
Code:
					while ( cur < end )
						*cur++ = palette[bin.ReadByte()];
In the Frame constructor in Animations.cs (line 503ish)...
I'm guessing that the cur pointer is somehow reading past the end of the stream? :|
 

Jeff

Lord
KevinEvans;845606 said:
Is there anyway that I could catch the error beforehand?
All I know is it's being caused by:
Code:
					while ( cur < end )
						*cur++ = palette[bin.ReadByte()];
In the Frame constructor in Animations.cs (line 503ish)...
I'm guessing that the cur pointer is somehow reading past the end of the stream? :|

right, its going outside the memory reserved for whatever it is pointing to. It would be better to just add a limit as to how big cur is, and check it in the while loop, rather then try catching.
 
with out seeing more of the code and knowing exactly what all the variable are, types they are and list limits set, it is hard to fully tell

but the problem maybe is this: you are increasing cur BEFORE the read, so the 1st read (which should be point 0, is actualy being read into point 1)
try changing:
Code:
					while ( cur < end )
						*cur++ = palette[bin.ReadByte()];
to
Code:
					while ( cur < end )
					{
						*cur = palette[bin.ReadByte()];
						cur++;
					}
 

Jeff

Lord
Lord_Greywolf;845646 said:
with out seeing more of the code and knowing exactly what all the variable are, types they are and list limits set, it is hard to fully tell

but the problem maybe is this: you are increasing cur BEFORE the read, so the 1st read (which should be point 0, is actualy being read into point 1)
try changing:
Code:
					while ( cur < end )
						*cur++ = palette[bin.ReadByte()];
to
Code:
					while ( cur < end )
					{
						*cur = palette[bin.ReadByte()];
						cur++;
					}

Uhhh, no...

++cur is increase before the read
cur++ is after.

Both pieces of code you posted are EXACTLY the same.
 

Sid_Choudhry

Wanderer
Hi !! This is me Sid ... Big Sucker of Ultima SDK ......
Got this forum very help full thanks a lot Jeff ....
I was facing the same Error Buh now I'm OK :)
 
Top