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. Working with a service, how to debug? Instant memory fault

Working with a service, how to debug? Instant memory fault

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminwindows-admindebuggingperformancetutorial
13 Posts 4 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.
  • L Lost User

    Well, You seem to ask a similar question every few years. [The answer remains the same.](https://www.codeproject.com/Messages/5497597/Re-Application-launched-by-another-program-how-to)

    C Offline
    C Offline
    charlieg
    wrote on last edited by
    #3

    And the beginning of my old post was "Having a senior moment..." thanks for the reminder

    Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

    L 1 Reply Last reply
    0
    • C charlieg

      And the beginning of my old post was "Having a senior moment..." thanks for the reminder

      Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #4

      Yep, For some reason there are no articles here on codeproject about GFlags. Found an old article you can read. [How to debug a process as soon as it starts with WinDbg or Visual Studio 2010](https://bugslasher.net/2011/03/26/how-to-debug-a-process-as-soon-as-it-starts-with-windbg-or-visual-studio-2010/) Just post again if you have any trouble.

      1 Reply Last reply
      0
      • C charlieg

        Context: Windows Server 2012 64 bit, everything else is 32 bit. So, I have a very simple application using tcpip that has worked fine for years. This application exists in the structure of another var application. Using a config file, the var knows to launch my code and connect - it's the way the var allows 3rd parties to extend services. In the environment that works, the oem app and mine runs in user space (see note below). From the user application window, I launch it, everything starts, like is good. It's worked for decades. In present time, I need to start the oem app as a service. The app starts, launches my application (app runs under a service account) where upon my app C000005s to death. No code has changed. C00005 exceptions are usually obvious to track down - look for the smoking hole in the ground. This one is a little sneaky since it's a few degrees off from my keyboard. I have an assert and a DebugAssert athe very beginning of my application - c5s and no prompts. If I launch my app from my command line - it starts and waits on the socket connection. ----------------------------------------- So any ideas how to catch my app/service starting up? Can I add code to the app? My feeling is that this is system related, but well anyway

        Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

        A Offline
        A Offline
        Andre Oosthuizen
        wrote on last edited by
        #5

        Since your application has been working fine in the user space, but encounters issues when running as a service, it's possible that there could be compatibility problems between your application and the service environment. You can try running your application in different compatibility modes (e.g., Windows XP, Windows 7) to see if it runs or not. You can also check if your application relies on any external dependencies such as libraries, frameworks, or drivers. Make sure that these dependencies are compatible with Windows Server 2012 64-bit. Outdated or incompatible dependencies can sometimes cause unexpected crashes or exceptions.

        C 1 Reply Last reply
        0
        • A Andre Oosthuizen

          Since your application has been working fine in the user space, but encounters issues when running as a service, it's possible that there could be compatibility problems between your application and the service environment. You can try running your application in different compatibility modes (e.g., Windows XP, Windows 7) to see if it runs or not. You can also check if your application relies on any external dependencies such as libraries, frameworks, or drivers. Make sure that these dependencies are compatible with Windows Server 2012 64-bit. Outdated or incompatible dependencies can sometimes cause unexpected crashes or exceptions.

          C Offline
          C Offline
          charlieg
          wrote on last edited by
          #6

          I'll try the different modes - good suggestion. As for the dependency question, I would think if such were the case it would not work standalone. This is a *very* simple program that acts as a network connection to simulate old hardware. Trivial UI (About...) and a socket connection. But we'll see. I just feel a forehead slapping moment coming on :)

          Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

          L 1 Reply Last reply
          0
          • C charlieg

            I'll try the different modes - good suggestion. As for the dependency question, I would think if such were the case it would not work standalone. This is a *very* simple program that acts as a network connection to simulate old hardware. Trivial UI (About...) and a socket connection. But we'll see. I just feel a forehead slapping moment coming on :)

            Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #7

            charlieg wrote:

            Trivial UI (About...) and a socket connection.

            Just wanted to mention that you cannot create a process with a GUI inside of session 0 where the system services resides. All window creation will fail. Also, if you are using the old WSAAsyncSelect/ WSAAsyncGetHostByAddr and so forth... those will all fail. Make sure you aren't using any of the old "Async" winsock functions.

            C 2 Replies Last reply
            0
            • L Lost User

              charlieg wrote:

              Trivial UI (About...) and a socket connection.

              Just wanted to mention that you cannot create a process with a GUI inside of session 0 where the system services resides. All window creation will fail. Also, if you are using the old WSAAsyncSelect/ WSAAsyncGetHostByAddr and so forth... those will all fail. Make sure you aren't using any of the old "Async" winsock functions.

              C Offline
              C Offline
              charlieg
              wrote on last edited by
              #8

              Excellent point, but one of the issues already identified in this migration process is that session 0 has no access to the printer interfaces. So the next step was to have the service run as a specific user. This is where I am right now. And thank you for all the notes on WSA*, I'll check for anything like that. Interestingly, this app is the parent of another application that seems to run just fine (same socket infrastructure). Edited: no longer sure of the above statement.

              Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

              1 Reply Last reply
              0
              • C charlieg

                Context: Windows Server 2012 64 bit, everything else is 32 bit. So, I have a very simple application using tcpip that has worked fine for years. This application exists in the structure of another var application. Using a config file, the var knows to launch my code and connect - it's the way the var allows 3rd parties to extend services. In the environment that works, the oem app and mine runs in user space (see note below). From the user application window, I launch it, everything starts, like is good. It's worked for decades. In present time, I need to start the oem app as a service. The app starts, launches my application (app runs under a service account) where upon my app C000005s to death. No code has changed. C00005 exceptions are usually obvious to track down - look for the smoking hole in the ground. This one is a little sneaky since it's a few degrees off from my keyboard. I have an assert and a DebugAssert athe very beginning of my application - c5s and no prompts. If I launch my app from my command line - it starts and waits on the socket connection. ----------------------------------------- So any ideas how to catch my app/service starting up? Can I add code to the app? My feeling is that this is system related, but well anyway

                Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                J Offline
                J Offline
                jschell
                wrote on last edited by
                #9

                charlieg wrote:

                C000005s to death

                Memory error. Standard problem. The environment is different so the execution flow is different. It didn't show up before because you got lucky. Now it does. If you have a testing framework you can use a memory check library to debug. Other than that you might also want to set it up for a delayed start. Or better if there are other dependent services make sure those are in the dependency list. The start up order is not deterministic unless explicit ordering is in place.

                C 1 Reply Last reply
                0
                • J jschell

                  charlieg wrote:

                  C000005s to death

                  Memory error. Standard problem. The environment is different so the execution flow is different. It didn't show up before because you got lucky. Now it does. If you have a testing framework you can use a memory check library to debug. Other than that you might also want to set it up for a delayed start. Or better if there are other dependent services make sure those are in the dependency list. The start up order is not deterministic unless explicit ordering is in place.

                  C Offline
                  C Offline
                  charlieg
                  wrote on last edited by
                  #10

                  Yeah, I know what it means :), and clearly you are correct that the environment has changed. As I said in another comment, its sister program works fine and is nigh identical to the one misbehaving.

                  Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                  1 Reply Last reply
                  0
                  • L Lost User

                    charlieg wrote:

                    Trivial UI (About...) and a socket connection.

                    Just wanted to mention that you cannot create a process with a GUI inside of session 0 where the system services resides. All window creation will fail. Also, if you are using the old WSAAsyncSelect/ WSAAsyncGetHostByAddr and so forth... those will all fail. Make sure you aren't using any of the old "Async" winsock functions.

                    C Offline
                    C Offline
                    charlieg
                    wrote on last edited by
                    #11

                    Yeah, this is becoming an unexpected train wreck. This code was written back in Windows Xp land and possibly earlier.

                    Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                    J 1 Reply Last reply
                    0
                    • C charlieg

                      Yeah, this is becoming an unexpected train wreck. This code was written back in Windows Xp land and possibly earlier.

                      Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                      J Offline
                      J Offline
                      jschell
                      wrote on last edited by
                      #12

                      charlieg wrote:

                      This code was written back in Windows Xp land

                      If it was me I would just say it needs to keep being run as an app or it needs to be refactored. Perhaps not completely refactored but enough so you (and future developers) can have a chance at maintaining it. I think actually I would start with the first solution - question why it needs to be run as a service.

                      C 1 Reply Last reply
                      0
                      • J jschell

                        charlieg wrote:

                        This code was written back in Windows Xp land

                        If it was me I would just say it needs to keep being run as an app or it needs to be refactored. Perhaps not completely refactored but enough so you (and future developers) can have a chance at maintaining it. I think actually I would start with the first solution - question why it needs to be run as a service.

                        C Offline
                        C Offline
                        charlieg
                        wrote on last edited by
                        #13

                        Thinking along the same lines. What's driving the need to do this is the 3rd party emulation system. Customer wants this system to fit into their new, super secure cloud system with network licenses, etc. Lots of requirements/desires that collide with each other. The good side of things is that the Windows side of the code is minimal - it just provides a framework for the parts that actually do all the work. Refactoring is exactly what is going on.

                        Charlie Gilley “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759 Has never been more appropriate.

                        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