c# -- 堆栈 cookie 检测代码检测到基于堆栈的缓冲区溢出

标签 c# .net memory

我有一个长时间运行的 i/o 繁重(网络/磁盘)多线程 c# 桌面应用程序,它偶尔会因“堆栈 cookie 检测代码检测到基于堆栈的缓冲区溢出”而崩溃。

崩溃线程的典型堆栈跟踪如下所示。

该程序运行 30 分钟到 6 小时之间的任何时间,然后它通常会因类似的堆栈而崩溃。

我在崩溃期间检查了其他应用程序线程的堆栈跟踪,并没有注意到任何模式。

我认为可能存在硬件问题,但机器上有很多事件并且没有其他损坏迹象(应用程序崩溃、事件日志错误等)。

C# 应用程序不使用 unsafe block 和没有使用 unsafe 的库据我确定的 block 。

两个问题:

  • 是否可以在下面的跟踪中获取 System.ni.dll 调用的符号?
  • 我该如何确定崩溃的原因? (我最怀疑的是框架错误。)

  • 我的系统是 i5-4790k(未超频),Windows 2012R2,面向 .net 4.6 x64,已完全修补。

    Visual Studio 2015,已完全修补。

    运行 Debug build 。
    clr.dll!__report_gsfailure()    Unknown
    clr.dll!SafeHandle::Release(bool)   Unknown
    clr.dll!SafeHandle::Dispose(void)   Unknown
    clr.dll!SafeHandle::DisposeNative(class SafeHandle *)   Unknown
    System.ni.dll!00007ffa765ddc4b()    Unknown
    System.ni.dll!00007ffa765dda8a()    Unknown
    System.ni.dll!00007ffa765e7e0e()    Unknown
    System.ni.dll!00007ffa765c420f()    Unknown
    System.ni.dll!00007ffa765c41d4()    Unknown
    mscorlib.ni.dll!00007ffa7740f18a()  Unknown
    System.ni.dll!00007ffa76b19bbf()    Unknown
    System.ni.dll!00007ffa765e0d0b()    Unknown
    System.ni.dll!00007ffa7657ac4f()    Unknown
    System.ni.dll!00007ffa765e0508()    Unknown
    System.ni.dll!00007ffa765e0319()    Unknown
    System.ni.dll!00007ffa765e714d()    Unknown
    System.ni.dll!00007ffa765e6cdd()    Unknown
    System.ni.dll!00007ffa765e0157()    Unknown
    System.ni.dll!00007ffa765dfe48()    Unknown
    System.ni.dll!00007ffa765dfdb5()    Unknown
    System.ni.dll!00007ffa765dfa0d()    Unknown
    System.ni.dll!00007ffa765de83d()    Unknown
    System.ni.dll!00007ffa765de401()    Unknown
    System.ni.dll!00007ffa765de2e0()    Unknown
    System.ni.dll!00007ffa765dacac()    Unknown
    System.ni.dll!00007ffa765da9f0()    Unknown
    System.ni.dll!00007ffa765da22e()    Unknown
    System.ni.dll!00007ffa765d7fc7()    Unknown
    System.ni.dll!00007ffa765d743d()    Unknown
    System.ni.dll!00007ffa76579af6()    Unknown
    00007ffa19832eb7()  Unknown
    00007ffa1978eb0f()  Unknown
    00007ffa19844cfa()  Unknown
    00007ffa199e83d7()  Unknown
    00007ffa1978ce48()  Unknown
    00007ffa1978ccb5()  Unknown
    00007ffa199e810f()  Unknown
    mscorlib.ni.dll!00007ffa77d37116()  Unknown
    mscorlib.ni.dll!00007ffa77d22a90()  Unknown
    mscorlib.ni.dll!00007ffa77dfa795()  Unknown
    mscorlib.ni.dll!00007ffa773d2c97()  Unknown
    mscorlib.ni.dll!00007ffa773fa77e()  Unknown
    mscorlib.ni.dll!00007ffa773fa617()  Unknown
    mscorlib.ni.dll!00007ffa773d2f3d()  Unknown
    mscorlib.ni.dll!00007ffa773d2608()  Unknown
    mscorlib.ni.dll!00007ffa77386b50()  Unknown
    clr.dll!CallDescrWorkerInternal()   Unknown
    clr.dll!CallDescrWorkerWithHandler(struct CallDescrData *,int)  Unknown
    clr.dll!MethodDescCallSite::CallTargetWorker(unsigned __int64 const *)  Unknown
    clr.dll!QueueUserWorkItemManagedCallback(void *)    Unknown
    clr.dll!Frame::Push(void)   Unknown
    clr.dll!Frame::Push(void)   Unknown
    clr.dll!Frame::Push(void)   Unknown
    clr.dll!ManagedPerAppDomainTPCount::DispatchWorkItem(bool *,bool *) Unknown
    clr.dll!ManagedPerAppDomainTPCount::DispatchWorkItem(bool *,bool *) Unknown
    clr.dll!ThreadpoolMgr::ExecuteWorkRequest(bool *,bool *)    Unknown
    clr.dll!ThreadpoolMgr::WorkerThreadStart(void *)    Unknown
    clr.dll!Thread::intermediateThreadProc(void *)  Unknown
    kernel32.dll!BaseThreadInitThunk()  Unknown
    ntdll.dll!RtlUserThreadStart()  Unknown
    

    最佳答案

    我遇到了类似的行为。我想这是 RyuJIT 编译器中的一个错误。为避免这种情况,您需要使用 <useLegacyJit enabled="1" /> 回退到 JIT64在 app.config 中。像这样:

    <runtime>
      <useLegacyJit enabled="1" />
    </runtime>
    

    关于c# -- 堆栈 cookie 检测代码检测到基于堆栈的缓冲区溢出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40623274/

    相关文章:

    c# - 从窗体打开 WPF 窗口后,WinForms 应用程序更改其缩放比例

    c# Class Names - 关于如何命名类的约定

    c# - 用 C# 合成声音

    c# - 在 C# 中使用 Powershell 远程调用的内存泄漏

    c - 从C中的物理内存地址读取结构

    c# - 强制约束问题

    c# - 新的System.Drawing.Font代码隐藏

    c# - 有什么办法可以让MemoryCache过期暂停一段时间?

    .net - 如何上传到 Azure Blob 存储而不覆盖?

    excel - 如何修复运行时错误 '7' 内存不足,即使在保存、关闭、重新启动计算机后该错误仍然存​​在