9

我有这段代码:

private void AnswerToCe(int currentBlock, int totalBlock = 0)
{
    byte[] bufferToSend;
    byte[] macDst = mac;
    byte[] macSrc = ConnectionManager.SInstance.GetMyMAC();
    byte[] ethType;
    byte[] header;

    if (Function == FlashFunction.UPLOAD_APPL || Function == FlashFunction.UPLOAD_BITSTREAM)
    {
        ethType = BitConverter.GetBytes((ushort)EthType.ETH_TYPE_UPLOAD);
        ethType = new byte[] { ethType[1], ethType[0] };
        header = Header.GetBytes((ushort)binaryBlocks.Count, (ushort)(currentBlock + 1), (ushort)binaryBlocks[currentBlock].Length);
        int index = 0;
        bufferToSend = new byte[macDst.Length + macSrc.Length + ethType.Length + header.Length + binaryBlocks[currentBlock].Length];
        Array.Copy(macDst, 0, bufferToSend, index, macDst.Length);
        index += macDst.Length;
        Array.Copy(macSrc, 0, bufferToSend, index, macSrc.Length);
        index += macSrc.Length;
        Logger.SInstance.Write(index.ToString(), "test index pre");
        Array.Copy(ethType, 0, bufferToSend, index, ethType.Length);
        index += ethType.Length;
        Logger.SInstance.Write(index.ToString(), "test index post");
        Array.Copy(header, 0, bufferToSend, index, header.Length);
        index += header.Length;
        Array.Copy(binaryBlocks[currentBlock], 0, bufferToSend, index, binaryBlocks[currentBlock].Length);
    }

如果我在调试模式下构建我的应用程序,一切正常,test index pre打印 12 并test index post打印 14。在Optimize code未选中的发布模式下相同。如果我使用Optimize code检查test index post打印 18 而不是 14进行测试。
如果我替换index += ethType.Length;index += 2;. 似乎只有index++;index++;在工作。
我在一个空的应用程序中尝试了这段代码,总和还可以。
应用程序是多线程的,但这里没有并发。
来自 DLL 的反编译代码似乎没问题。
任何想法为什么会发生这种情况?

编辑:仅在为 x64 编译应用程序时发生。x86 没问题。
编辑 3:构建环境的一些信息:
visual studio 15.0.0-RTW+26228.4
框架 4.7.02053
可以在框架 4.6.2 和 4.7 上触发此问题。其他框架未经过测试。
编辑 5:新的、更小的示例项目。不需要依赖项。
编辑 6:这里测试项目的反汇编。(这里太长了,不能发)

4

1 回答 1

0

这是 RyuJIT 中已经报告的错误,更多详细信息请点击此处。将很快在修补程序中修复。

于 2017-08-04T08:11:33.550 回答