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. ATL / WTL / STL
  4. ATL service crashes when being stopped by the system

ATL service crashes when being stopped by the system

Scheduled Pinned Locked Moved ATL / WTL / STL
c++debugging
2 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.
  • C Offline
    C Offline
    Cruelty
    wrote on last edited by
    #1

    My ATL service crashes when it is being stopped by the system (its startup mode is "automatic"). This happens only if the service is running on Windows XP and is being stopped automatically (not manually). The source code: HRESULT CMyServiceModule::PostMessageLoop() { RevokeClassObjects(); LogEvent(_T("Service stopped")); CoUninitialize(); SetServiceStatus(SERVICE_STOPPED); // <--- this line causes the crash return CAtlServiceModuleT::PostMessageLoop(); } The debugger shows that m_hServiceStatus is NULL. Thank you in advance for any ideas.

    M 1 Reply Last reply
    0
    • C Cruelty

      My ATL service crashes when it is being stopped by the system (its startup mode is "automatic"). This happens only if the service is running on Windows XP and is being stopped automatically (not manually). The source code: HRESULT CMyServiceModule::PostMessageLoop() { RevokeClassObjects(); LogEvent(_T("Service stopped")); CoUninitialize(); SetServiceStatus(SERVICE_STOPPED); // <--- this line causes the crash return CAtlServiceModuleT::PostMessageLoop(); } The debugger shows that m_hServiceStatus is NULL. Thank you in advance for any ideas.

      M Offline
      M Offline
      Martin Koorts
      wrote on last edited by
      #2

      Hi It's a bit weird since m_hServiceStatus is a member of the statically allocated CMyServiceModule class. Anyway, what I'll try to do is; see if the m_hServiceStatus is non-NULL when the PostMessageLoop function is entered. If so, RevokeClassObjects or CoUnitialize (or another thread) will be fiddling with the module object. If you can't find whatever code is setting the m_hServiceStatus to NULL, you may find it's address (say after the service is started) and set a breakpoint that monitors an address (ie. set a Condition to 'when (*(int*) 0x12345678) changes' and 0x12345678 is the address of the m_hServiceStatus data member). Are you sure it's not CoUnitialize causing the exception? - typically things will go bonkers if you still have outstanding COM references and call CoUninitialize. Could it be another app still has COM references to objects allocated by the ATL service? Martin

      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