Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Infinite loop when debugging in Visual Studio 2010

I have a strange issue with VS2010 (building a large C++ project). 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. I also tried F11 to step into main(), but no effect. The task manager shows an instance of my application, and the console says nothing but "xxx.dll Symbols loaded.". 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. It seems that the library has some kind of loading routite, which is called before the execution of main(). Even though I solved my current problem, I still would like to know: how to detect such kind of problems?

like image 244
Violin Yanev Avatar asked Sep 12 '12 20:09

Violin Yanev


1 Answers

I think I found the problem. In one of my DLLs I had a singleton class. In the header file i had an getter LogManager::instance() and an destroyer void LogManager::destroyInstance(). The instance was defined in the .cpp file but not statically but just as global variable

LogManager* sInstance = new LogManager;

and the instance() function just returned that variable and the destroyInstance() function deleted it. So I removed the global variable and created that instance within the instance() function

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? Maybe thats an hint for people with similar problems.

like image 140
C0dR Avatar answered Oct 20 '22 19:10

C0dR