简体   繁体   English

在Visual Studio 2010中进行调试时无限循环

[英]Infinite loop when debugging in Visual Studio 2010

I have a strange issue with VS2010 (building a large C++ project). 我对VS2010有一个奇怪的问题(构建一个大的C ++项目)。 When starting to debug, the execution goes in something like an infinite loop. 在开始调试时,执行就像无限循环一样。 I put the a breakpoint at the first line of main(), but the breakpoint is never reached. 我将断点放在main()的第一行,但是从未到达断点。 I also tried F11 to step into main(), but no effect. 我也试过F11进入main(),但没有效果。 The task manager shows an instance of my application, and the console says nothing but "xxx.dll Symbols loaded.". 任务管理器显示我的应用程序的一个实例,控制台只显示“xxx.dll符号已加载”。 I tried to pause the execution, but I get thrown into some assembly loop, here is the assembly if someone can read it: 我试图暂停执行,但是我被抛入一些程序集循环,如果有人可以读取它,这是程序集:

0000000077226129  lea         rdx,[rsp+88h]  
0000000077226131  xor         ecx,ecx  
0000000077226133  call        0000000077231650  
0000000077226138  mov         dword ptr [rsp+30h],eax  
000000007722613C  test        eax,eax  
000000007722613E  js          000000007725E73F  
0000000077226144  cmp         dword ptr [7731201Ch],r14d  
000000007722614B  je          0000000077226129  

Can someone tell me or at least point me to how to approach this problem? 有人能告诉我或者至少指出我如何处理这个问题?

Edit: I found out that when removing one of the shared libraries (FlyCapture2 developed by Point Grey Research), the application starts normally. 编辑:我发现当删除其中一个共享库(Point Grey Research开发的FlyCapture2)时,应用程序正常启动。 It seems that the library has some kind of loading routite, which is called before the execution of main(). 似乎库有某种加载例程,在执行main()之前调用它。 Even though I solved my current problem, I still would like to know: how to detect such kind of problems? 即使我解决了当前的问题,我仍然想知道:如何检测这类问题?

I think I found the problem. 我想我发现了这个问题。 In one of my DLLs I had a singleton class. 在我的一个DLL中,我有一个单例类。 In the header file i had an getter LogManager::instance() and an destroyer void LogManager::destroyInstance() . 在头文件中,我有一个getter LogManager :: instance()和一个destroyer void LogManager :: destroyInstance() The instance was defined in the .cpp file but not statically but just as global variable 实例是在.cpp文件中定义的,但不是静态的,而是全局变量

LogManager* sInstance = new LogManager;

and the instance() function just returned that variable and the destroyInstance() function deleted it. 并且instance()函数刚刚返回该变量,而destroyInstance()函数将其删除。 So I removed the global variable and created that instance within the instance() function 所以我删除了全局变量并在instance()函数中创建了该实例

void LogManager::instance()
{
    static LogManager*  sInstance = 0;
        if(!sInstance)
            sInstance = new LogManager;
    return sInstance;
}

and the problem was gone. 而问题已经消失。 So I think maybe the global variable in that DLL caused an infinite loop during loading of that DLL? 所以我想也许DLL中的全局变量在加载DLL时会导致无限循环? Maybe thats an hint for people with similar problems. 也许这是有类似问题的人的暗示。

How to connect to DLL(s) correctly is a big problem.It is before applications so we are hard to find it and solve it.But when I hava a question about DLL(s),I would also look for answers on the Internet.And every error has its own serial number.That's the key.It also says "LNK**** ........" in the "Error List".So I can find it ,and even solve it by myself according to the information from others. 如何正确连接到DLL是一个大问题。它在应用程序之前,所以我们很难找到并解决它。但是当我讨论关于DLL的问题时,我也会在互联网上寻找答案每个错误都有自己的序列号。那就是关键。它还在“错误列表”中说“LNK **** ........”。所以我可以找到它,甚至可以解决它我根据别人的信息。

PS:Your code is called "Machine Instruction".It's part of Principles of Computer. PS:你的代码叫做“机器指令”。它是计算机原理的一部分。

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

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