一台电脑上出现堆栈溢出错误,另一台电脑上没有错误?
问题是这样的:
我的笔记本电脑上有一个用 Delphi XE 开发的项目。当我在台式电脑上运行它时,我在这一行收到“堆栈溢出”异常(我还在代码的不同部分使用了 Writeln() ,而这一行就是问题的根源)
: S_List.LoadFromFile('Test.txt');
(S_List 是在此行之前创建的本地 TStringList)
但是,当我在笔记本电脑上运行相同的项目时,它可以正常工作,没有任何错误或异常。问题不可能是方法本身,因为当我更改整个部分并使用“TStreamReader”再次写入时,会发生相同的异常。这次是在 StreamReader.ReadLine()
上。另外,我更改了文件位置、名称......问题仍然出现。
这似乎是一个文件系统问题,但我完全不知道这是如何发生的。
有什么想法吗?可能是因为病毒或恶意软件吗?
PS:两者(笔记本电脑和PC)都有Win7和Delphi XE。此外,两者都有 2GB RAM。
编辑:需要明确的是,我提出这个问题的主要目标不是找到异常所在(这不可能通过给出 1 行代码来实现,不是吗?)。但是,为什么这个错误在不同的硬件中不一致呢?这能有什么理由呢?另外,我怎样才能找到导致这种不一致的原因呢?
The problem is this:
I have a project developed in Delphi XE on my laptop. When I run it on my desktop PC, I get a "stack overflow" exception on this line (I also used Writeln() on different parts of the code and just this line is the source of the problem):
S_List.LoadFromFile('Test.txt');
(S_List is a local TStringList which is created before this line)
But, when I run the same exact project on my laptop, it works without any errors or exceptions at all. The problem can't be the method itself, because when I change the whole part and write it again using 'TStreamReader', the same exception occurs. This time on StreamReader.ReadLine()
. Also, I changed the file location, name, .... Problem still occurs.
It seems like a file system problem, but I don't have the slightest idea how this happens.
Any ideas? Can it be because of a virus or a malware?
P.S: Both (laptop and PC) have Win7 and Delphi XE. Also, both have 2GB RAM.
Edit: Just to be clear, my main goal for asking this question is not finding where the exception lies (that can't happen by giving 1 line of code, can it?). But, instead, how come this error is NOT consistant in different hardwares? What reason can that have? Also, how can I find what causes this inconsistency?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我的猜测(我们所能做的就是猜测)是您有一个未初始化的局部变量。或者释放后访问的对象。我不确定这如何导致堆栈溢出,但在这种情况下几乎任何事情都是可能的。与 madExcept 一样,您应该使用具有完整调试设置的 FastMM。
My guess, and guessing is all we can do, is that you have an uninitialised local variable. Or an object that you access after having freed it. I'm not sure how that leads to your stack overflow but almost anything is possible with such a scenario. As well as madExcept you should be using FastMM with full debug settings.
当有人难以使用 Delphi 应用程序在特定环境中诊断异常时,我强烈建议 madExcept。它对于非商业用途是免费的,设置非常简单,而且非常有帮助。安装它,为您的项目启用它,构建调试版本,并将其部署到有问题的机器。当异常发生时,您应该获得有关问题发生位置的非常详细的调用堆栈。
When someone has difficulty diagnosing an exception in a specific environment with a Delphi application I strongly suggest madExcept. It's free for non-commercial use, very easy to setup, and VERY helpful. Install it, enable it for your project, build a debug build, and deploy it to the problem machine. When the exception occurs, you should get a very detailed call stack of where the issue happened.
我会检查这一点:
I would check this:
检查重复的 DCU,如果可能,对已安装的库和应用程序进行完整构建,以查看错误是否仍然存在。
Check for duplicate DCU's and if possible do a full build of installed libraries and the application to see if the error persists.