zengqh / slimdx

Automatically exported from code.google.com/p/slimdx
0 stars 0 forks source link

AccessViolationException => "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." #387

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
SlimDX, november release, direct3d10, visual studio 2008

Whenever you convert a pool twice to an effect, you get an AccessViolation.

pool = EffectPool.FromFile(Device, "Common.fxh", "fx_4_0", 
ShaderFlags.None, EffectFlags.None);
Effect e = pool.AsEffect();
poolView = pool.AsEffect().GetVariableByName("View").AsMatrix();

Their is no real need to do this, but it took me a while to trace the 
error.  A simple "is already created exception" would be easier to 
understand.

kind regards

Alexander

Original issue reported on code.google.com by amuylaer...@gmail.com on 29 Dec 2008 at 10:58

GoogleCodeExporter commented 9 years ago
This appearst to be related to a deep-rooted problem in the way we handle COM 
objects via our object table. The code for AsEffect() calls the native 
AsEffect(), 
which returns the same COM object all the time. However our object table 
prematurely 
Release()'s this instance, destabilizing the native API.

The simple workaround is, as you noted, to not call AsEffect more than once. 
This 
should involve caching the resulting Effect reference, since the restriction is 
for 
the lifetime of the EffectPool instance in question.

We will be able to fix this issue more completely when we correct the object 
table 
problems outlined in bug #359.

Original comment by josh.petrie on 6 Jan 2009 at 2:35

GoogleCodeExporter commented 9 years ago

Original comment by josh.petrie on 6 Jan 2009 at 2:35

GoogleCodeExporter commented 9 years ago

Original comment by josh.petrie on 6 Jan 2009 at 2:35

GoogleCodeExporter commented 9 years ago
Fixed.

Original comment by josh.petrie on 1 Feb 2009 at 11:08