SuspendThread and StackWalk64
-
If you know anything at all about either of these two functions, it's that SuspendThread[^] can be dangerous (primarily because it creates application deadlocks if not properly used). Read, Jochen Kalmbach's WebLog [^] However, if you want to use the StackWalk64[^]function from the dbghelp.dll, you must call SuspendThread to get relavant and useful results. So, what is the PROPER way to use SuspendThread? How could you possibly know of all the mechanisms and objects that are currently activated by a thread?
-
If you know anything at all about either of these two functions, it's that SuspendThread[^] can be dangerous (primarily because it creates application deadlocks if not properly used). Read, Jochen Kalmbach's WebLog [^] However, if you want to use the StackWalk64[^]function from the dbghelp.dll, you must call SuspendThread to get relavant and useful results. So, what is the PROPER way to use SuspendThread? How could you possibly know of all the mechanisms and objects that are currently activated by a thread?
Baltoro wrote:
However, if you want to use the StackWalk64[^]function from the dbghelp.dll, you must call SuspendThread to get relavant and useful results.
Only if you want to walk the stack of a thread other than the current one. This is fairly obvious, if you didn't suspend the other thread it's stack would likely change while you are walking it. The only problem in suspending another thread is that, as mentioned, any other threads waiting on the the suspended thread are going to keep waiting. This isn't a problem unless their waits time-out, even this isn't a problem because it tests your codes response to a rare error condition.
...cmk The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying. - John Carmack
-
Baltoro wrote:
However, if you want to use the StackWalk64[^]function from the dbghelp.dll, you must call SuspendThread to get relavant and useful results.
Only if you want to walk the stack of a thread other than the current one. This is fairly obvious, if you didn't suspend the other thread it's stack would likely change while you are walking it. The only problem in suspending another thread is that, as mentioned, any other threads waiting on the the suspended thread are going to keep waiting. This isn't a problem unless their waits time-out, even this isn't a problem because it tests your codes response to a rare error condition.
...cmk The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying. - John Carmack