Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. SuspendThread and StackWalk64

SuspendThread and StackWalk64

Scheduled Pinned Locked Moved C / C++ / MFC
questioncom
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Baltoro
    wrote on last edited by
    #1

    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?

    C 1 Reply Last reply
    0
    • B Baltoro

      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?

      C Offline
      C Offline
      cmk
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • C cmk

        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

        B Offline
        B Offline
        Baltoro
        wrote on last edited by
        #3

        ...thanks, ...cmk I was referring to a remote thread, even though it was unstated. I asked this question over on the Microsoft Technical Forums and got approximately the same answer. It isn't really a problem, I was just curious.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups