dx11 icon indicating copy to clipboard operation
dx11 copied to clipboard

Util.GetArray causes several runtime errors

Open hozuki opened this issue 9 years ago • 0 comments

The function Core.Util.GetArray uses a static array to lower array allocation costs, but newer version of SlimDX (currently I'm using SlimDX 4.0.13.44) seems to expect a array of exact length needed. For example, in LightingDemo, running this demo will throw a NullReferenceException, located at this line:

_fxPointLight.SetRawValue(new DataStream(array, false, false), array.Length);

With the help of the debugger I found that all fields of _fxPointLight became invalid. A watch on _fxPointLight shows that the change happens just after the _fxDirLight.SetRawValue call. So I canceled the static buffer and tried to create a new array of len bytes each time, and this modification worked. I suspect SlimDX neither fully checks the parameters nor handles this situation well and internal states of D3D just crash. This problem also affects other several demos.

hozuki avatar Apr 05 '16 10:04 hozuki