简体   繁体   English

应用程序启动时clr.dll中的缓冲区溢出

[英]Buffer Overflow in clr.dll at application start-up

I have two computers. 我有两台电脑。 Both work under Windows 7 Embedded and have same version of .Net 4.0 framework installed. 两者都可以在Windows 7 Embedded下运行,并且安装了相同版本的.Net 4.0框架。 My WinForms application works with no issues on one of them but fails at start-up with BEX in clr.dll on another. 我的WinForms应用程序在其中一个上可以正常工作,但在另一个中在clr.dll中使用BEX启动时失败。

Problem Event Name: BEX
Application Name:   Myapplication.exe
Application Timestamp:  5669ec33
Fault Module Name:  clr.dll
Fault Module Version:   4.0.30319.526
Fault Module Timestamp: 4eb3b6b1
Exception Offset:   002b65ec
Exception Code: c0000409
Exception Data: 00000000
OS Version: 6.1.7601.2.1.0.320.65
Locale ID:  1033
Additional Information 1:   a835
Additional Information 2:   a835052745ddb3bce091e0cd181de7e7
Additional Information 3:   7cb8
Additional Information 4:   7cb8eec426d05584b36071af9d74719d

What is very "strange" 什么很“奇怪”

I was able to find two things in my application that somehow have impact or provoke this problem. 我能够在应用程序中找到两件事,它们以某种方式影响或引发了这个问题。 First I found exact line of code.. I have few buttons that I manually create manually on UI thread. 首先,我找到了确切的代码行。我有几个按钮是在UI线程上手动创建的。 And if I remove next line my application starts. 如果我删除下一行,我的应用程序将启动。

btn.Font = new Font("Tahoma", 9, FontStyle.Bold, GraphicsUnit.Point, 0);

Second I noticed that if I use my debug logger which uses StackFrame to find out where log message is coming form, Application will crash with the same error in CLR but at some other place. 其次,我注意到,如果我使用调试记录器,该记录器使用StackFrame来查找日志消息的发送位置,则应用程序将在CLR中崩溃,但错误发生在其他地方。 Not at the line I mentioned above. 不在我上面提到的那条线上。

My two computers have different RAM. 我的两台计算机具有不同的RAM。 2GB and 1GB. 2GB和1GB。 Application fails on the second one with 1GB of memory. 应用程序在第二个具有1GB内存的应用程序上失败。 But application iself uses 30 MB and system has ~350 MB of free memory. 但是应用程序iself使用30 MB,系统具有约350 MB的可用内存。 Could memory be a reason ? 记忆可能是一个原因吗?

My research for the most part referred me to different hot-fixes issued by Microsoft. 我的研究大部分使我想到了Microsoft发布的不同修补程序。 I tried them but nothing helped. 我尝试了它们,但没有任何帮助。 I also tried to install .Net v4.5 but with the same negative result. 我也尝试安装.Net v4.5,但结果相同。

Where else I can start looking for the problem ? 我还能从哪里开始寻找问题?

... And yes, this problem does not show up when running application with attached debugger. ...是的,当运行带有附加调试器的应用程序时,不会出现此问题。

Update 更新资料

I just realised that "Exception Code: c0000409" means STATUS_STACK_BUFFER_OVERRUN. 我刚刚意识到“异常代码:c0000409”表示STATUS_STACK_BUFFER_OVERRUN。 This brings some sense to strange application behaviour that I have but still not clear why it works on one computer but does not work on another. 这给我所具有的奇怪应用程序行为带来了某种意义,但我仍然不清楚为什么它可以在一台计算机上运行而不能在另一台计算机上运行。

Solution finally found 终于找到解决方案

My application uses third party C# library which is actually a wrapper on top of calls to other native library. 我的应用程序使用第三方C#库,它实际上是对其他本机库的调用的包装。 I decompiled library and realised that calling convention is set to CallingConvention.Cdecl but as I see from Dependency Walker application, all methods in native library has CallingConvention.StdCall 我对库进行了反编译,并意识到将调用约定设置为CallingConvention.Cdecl,但是从Dependency Walker应用程序中看到,本机库中的所有方法都具有CallingConvention.StdCall

After changing calling convention and recompiling the library issue disappeared. 更改调用约定并重新编译后,库问题消失了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM