WinCE:调试版本有效,从流设备驱动程序读取时,发行版本崩溃 [英] WinCE: Debug version works, Release version crashes while reading from stream device driver

查看:243
本文介绍了WinCE:调试版本有效,从流设备驱动程序读取时,发行版本崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用平台构建器在Visual Studio 2005中创建Windows CE 6.0。我集成了流设备驱动程序(通过USB HID)。我还有一个小应用程序,用于打开与设备的连接并从中读取数据。当我构建此Windows CE 6.0的Debug-Version并在设备上对其进行调试时,我可以启动应用程序,并且与设备的通信可以正常进行。现在,我构建Windows CE 6.0的发行版(源代码无更改!),在设备上运行它并在设备上启动应用程序。当我尝试通过ReadFile()从设备读取数据时(我猜这会从流驱动程序调用XXX_Read()),我的Windows崩溃并重新启动。这太糟糕了,因为我无法调试Windows完全崩溃的CE ...(因为它在调试版本中不会崩溃;)。

i am creating a Windows CE 6.0 in Visual Studio 2005 with Platform builder. I integrated a stream device driver (via USB HID). I also have a small application that opens a connection to the device and reads data from it. When i build a Debug-Version of this Windows CE 6.0 and debug it on the device i can start the application and the communication to the device works fine. Now i build a Release-Version (no changes of Sources!) of the Windows CE 6.0, run it on the device and start the application on the device. When i try to read data from the device by ReadFile(), (i guess this calls XXX_Read() from the stream driver) my windows crashes and reboots. Its too bad, because i cant debug the CE where the windows exactly crashes... (because it does not crash in debug version ;).

两者之间有什么区别WinCE 6的调试和发行版本?是否有人暗示我需要仔细研究流设备驱动程序的哪一部分才能解决此问题?我知道在调试/发布中未采用项目设置。但是我想不出任何可能影响流设备驱动程序的设置。

What are the differences between Debug and Release Version of WinCE 6? Does anyone have a hint at which part of the Stream Device driver i need to have a closer look to solve this problem? I know that in Debug/Release the Project settings are not adopted. But i cant think of any setting that may influence the stream device driver.

问候

推荐答案

Release和Debug之间的最大区别是,在代码的Debug版本中,所有变量都初始化为零。在Release中,它们根本没有初始化,因此,在分配变量时,它们常常会以变量的存储位置中的任何非零垃圾结束。

The big difference between Release and Debug is that in a Debug build of code all variables get initialized to zero. In Release they do not get initialized at all and therefore often can end up with whatever non-zero garbage was in the storage location of the variable when it was allocated.

如果要在代码中创建指针,然后将其与 NULL 进行比较,则通常会遇到问题。调试版本将告诉您指针为 NULL ,因为它已初始化为零。在Release版本中,它的最终结果非零,然后尝试取消对指针中的垃圾的引用,这会导致访问冲突崩溃。

This is often a problem if you're creating pointers in your code and then checking them against NULL. A Debug build will tell you the pointer is NULL because it got initialized to zero. In Release it ends up non-zero, then you try dereferencing the garbage in the pointer and it causes an access violation crash.

故事的寓意:始终,始终用代码初始化变量。 ZeroMemory / memset 是您的朋友。

The moral of the story: always, always initialize your variables in code. ZeroMemory/memset is your friend.

这篇关于WinCE:调试版本有效,从流设备驱动程序读取时,发行版本崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆