Windows 8在Delphi项目上崩溃 [英] Esent crashes with Windows 8 on a Delphi project

查看:110
本文介绍了Windows 8在Delphi项目上崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在项目中广泛使用ESENT,并且我非常喜欢ESENT的工作原理.也很稳定!

I've been using ESENT for my projects quite extensively and I really love how easy and fast it works. And stable too!!

但是我在Windows 8上遇到了巨大的问题!!!无论我何时调用JetSetSystemParameter以外的其他方式(无论是动态还是静态地)链接到esent.dll,dll都会崩溃,将我的应用拖到悬崖上.

But I have a HUGE problem with Windows 8!!! Regardless of how I link to the esent.dll (dynamically or statically) whenever I call something other than JetSetSystemParameter, the dll is crashing, takig my app down the cliff.

不幸的是,我仍然无法运行它.我的代码在Windows 7或更早版本上运行没有问题.但是在Windows 8中,当我尝试创建实例(浮点无效操作)时,esent.dll崩溃.

Unfortunately I still can't get it running. My code had no problem running with Windows 7 or older. But with Windows 8 I get esent.dll crashing when I try to create an instance (floating point invalid operation).

我尝试了所有可能的调用约定.这绝对不是问题.我尝试了一些,发现了这种奇怪的情况:1.我使用VS 2012创建了一个演示应用程序,JetCreateInstance正常工作. 2. Delphi XE3中完全相同的代码将导致esent.dll崩溃. 3.我使用VS 2012创建了一个DLL,并导出了在上述演示应用程序中运行良好的方法,并认为这是一个Delphi错误. 4.然后,将DLL加载到演示的Delphi项目中(尝试使用6,XE2和XE3).调用方法和BOOM.同样的崩溃.

I tried all possible calling conventions. This is definitely NOT the problem. I tried some more and discovered this weird situation: 1. I created a demo application using VS 2012 and JetCreateInstance worked just fine. 2. Exactly the same code in Delphi XE3 will send esent.dll crashing. 3. I created a DLL using VS 2012, exporting the method that worked perfectly in the above demo app, thinking it's a Delphi bug. 4. And then I loaded the DLL in a demo Delphi project (tried with 6, XE2 and XE3). Called the method and BOOM. Same crash.

现在我的假设是Microsoft不允许?!?任何其他开发人员环境都可以与esent.dll一起正常使用. 这可能吗?

Now my assumption is that Microsoft won't allow?!? any other developer environment to work correctly with the esent.dll. Is this possible???

推荐答案

该错误(浮点无效操作)使问题听起来像是与浮点控制字有关.

The error, a floating point invalid operation, makes the problem sound as though it is related to the floating point control word.

默认情况下,Delphi会取消屏蔽浮点异常.因此,当代码要求浮点单元执行导致错误的操作时,FPU会发出信号,然后将其转换为异常.

By default Delphi unmasks floating point exceptions. So when code asks the floating point unit to perform operations that result in errors, the FPU signals which is then converted to an exception.

但是大多数其他Windows开发环境在FPU上掩盖了这些例外.在执行环境中屏蔽了FPU异常的前提下编写此类代码.但是,如果从Delphi调用DLL,则执行环境将具有未屏蔽的FPU异常,从而打破了这一假设.我怀疑如果掩盖FPU异常,那么您的问题将会消失.

But most other Windows development environments mask these exceptions on the FPU. Such code is written under the assumption that the execution environment has FPU exceptions masked. But if you call a DLL from Delp the execution environment will have unmasked FPU exceptions, breaking that assumption. I suspect that if you mask FPU exceptions then your problems will disappear.

要测试这是否是问题,只需将其添加到您的代码中即可,该代码将在其生命周期的早期执行:

To test if this is the problem, you can simply add this to your code, executed early in its life:

Set8087CW($027F);

这将屏蔽所有异常并将FPU控制字设置为默认Windows设置.

This will mask all exceptions and set the FPU control word to the default Windows setting.

从长远来看,您可能希望在每次调用此DLL之前掩盖异常,然后在对DLL的调用返回时恢复FPU控制字.

In the longer term you may wish to mask exceptions before each call to this DLL, and then restore the FPU control word when the call to the DLL returns.

使用Delphi提供的库对游戏来说是一个稍微危险的游戏,因为Set8087CW由于使用全局变量Default8087CW而具有线程安全性.如果您想了解有关该问题的更多信息,请参考 QC#107411 .

That is a slightly dangerous game using the libraries that are supplied with Delphi since Set8087CW is not threadsafe due to its use of the global variable Default8087CW. If you wish to read more about that issue, I refer you to QC#107411.

这篇关于Windows 8在Delphi项目上崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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