General list of value types with sequential layout and batch size & # 8594; BUG?

The following code throws an ExecutionEngineException when launching the release build executable (running the exe file ). Is this a mistake or is this normal behavior?

value type with batch size = 1:

[StructLayout(LayoutKind.Sequential, Pack = 1)] public struct RunLong { public byte Count; public long Value; public RunLong(byte count, long value) { Count = count; Value = value; } } 

Using the structure in the general list (T), adding values ​​and getting or setting its value leads to the failure of the executable file if it was created in the release mode. A crash does not occur when the executable is embedded in debug mode or when running code inside the visual studio debugger (debug or debug mode).

 List<RunLong> runs = new List<RunLong>(1024); for (int i = 0; i < 1000; i++) { runs.Add(new RunLong(1, i)); } RunLong last = runs[runs.Count - 1]; last.Count = (byte)(last.Count + 1); runs[runs.Count - 1] = last; 

Can anyone confirm this? Is there a reasonable explanation?

I am running VS 2010, .net 4, Win XP SP3

Thanks in advance!

+6
list generics struct
source share
2 answers

This issue was fixed in MS11-028 last week. See the weblog for more details.

+6
source share

This appears on the surface to be a bug in the JIT x86 engine. This is repeated only in the following circumstances.

  • Compile in retail
  • Compile for x86
  • Starting without Visual Studio Debugger (shown when using WinDbg)

It does not play in amd64 mode, although this makes me suspect this as

  • Alignment problem (error in code)
  • X86 JIT issue

I am not an expert in alignment by any means, but I believe that your code will be correct. Please report a connection error to ensure that the problem has been investigated, and add the error link in the comment section of my answer (I would like to track it internally).

+2
source share

All Articles