程序在开始运行前被卡住 [英] Program stuck before start running

查看:74
本文介绍了程序在开始运行前被卡住的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我的C ++程序(控制台应用程序)在进入main()函数之前就被卡住了(控制台已打开,什么也没发生).
(我检查了VS6和VS2010,并遇到了相同的问题)
在更改了我使用的一个库之后,这个问题开始了.

这个问题的原因可能是什么(库,相关的dll?)
如何检查程序卡在哪里?有没有推荐的工具来检查它?

谢谢,
Dotan Knaan

Hello,

My C++ program (console application)is stuck even before it get to the main() function (the console is open, and nothing happens).
(I check with VS6 and VS2010 and got the same problem)
This problem started after I changed one of the libraries that I use.

What can be the reason for this problem (the libraries, related dlls?)
How can I check where the program is stuck? Are there any recommended tools to check it?

Thanks,
Dotan Knaan

推荐答案

使用调试器并获取所有线程的堆栈跟踪.
Use a debugger and get stack traces for all the threads.


它很可能是全局变量(某类)初始化.

在代码进入main()函数之前,所有全局变量都作为CRT启动的一部分进行初始化(并在main()函数返回后清除).

开始调试,让它运行几秒钟,然后在调试器上按暂停键.调试器将中断,并向您显示当前的位置.猜测可能是无限循环,还是等待Mutex或Semaphore之类的东西.
It will most likely be a global variable (of a class) initialising.

All global variables are initialised as part of the CRT startup, before the code enters the main() function (and cleaned up after the main() function returns)

Start debugging and let it run for a few seconds, then hit pause on the debugger. The debugger will break and show you where it is currently up to. At a guess it will be either an infinite loop or waiting on something like a Mutex or Semaphore


在开发环境中运行时,您只需暂停程序并在堆栈窗口中查看(按住Ctrl-Alt-C组合键的位置).这将为您提供有关文件使用哪种方法以及问题出在哪里的信息(可能).

祝你好运!
When you run in the development environment you can simply pause the program and see in the stack window (Ctrl-Alt-C) where it is running at the time of pausing. This would give you some info on which method with the file and that be where the problem is (probably).

Good luck!


这篇关于程序在开始运行前被卡住的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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