首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RyuJIT C#错误和与/optimize的结果

RyuJIT C#错误和与/optimize的结果
EN

Stack Overflow用户
提问于 2017-08-02 12:53:18
回答 1查看 305关注 0票数 9

我有一段代码:

代码语言:javascript
复制
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:构建env的一些信息:

visual 15.0.0-RTW+26228.4

框架4.7.02053

可以在框架4.6.2和4.7上触发此问题。其他框架没有经过测试。

编辑5:新的、较小的示例项目。不需要依赖关系。

编辑6:拆卸测试项目这里。(时间太长,无法在此张贴)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-04 08:11:33

这是RyuJIT中已经报告的一个bug,更详细的这里。很快就会被修复。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45461443

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档