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. What kind of coding mistakes cause unexpected exits?

What kind of coding mistakes cause unexpected exits?

Scheduled Pinned Locked Moved C / C++ / MFC
c++debugginghelpperformancequestion
5 Posts 3 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.
  • T Offline
    T Offline
    TBC_DEV
    wrote on last edited by
    #1

    I have a C++ dll (native using MFC), it is used from a few different applications. It works much of the time and has no memory issues that Purify can see. But the dll sometimes exits for no reason. No error is reported, it is not a crash or lockup. Since the Dll exits, it causes the application that uses it to exit too. Having no error reported, closing the forms, and being intermitant makes this difficult to debug. Any advise about what to look for in the code that typically causes this type of behaviour (other than forgetting to return)? Yes, the debugger could help but I have not been able to reproduce on a development PC yet. TBC

    P I 2 Replies Last reply
    0
    • T TBC_DEV

      I have a C++ dll (native using MFC), it is used from a few different applications. It works much of the time and has no memory issues that Purify can see. But the dll sometimes exits for no reason. No error is reported, it is not a crash or lockup. Since the Dll exits, it causes the application that uses it to exit too. Having no error reported, closing the forms, and being intermitant makes this difficult to debug. Any advise about what to look for in the code that typically causes this type of behaviour (other than forgetting to return)? Yes, the debugger could help but I have not been able to reproduce on a development PC yet. TBC

      P Offline
      P Offline
      Perspx
      wrote on last edited by
      #2

      Sorry if this is pretty unhelpful :sigh: but you could (and this would be PRETTY laborious) open a file stream and write data to it when certain tasks are performed in the DLL and also (if you can) write a message to the file when the DLL exits to determine what has happened.. I'm pretty sure it's not a memory buffer overload.. This would result in the application crashing, not just exiting.. However I'm not certain so a memory issue could be the problem. Sorry I can't be of more help, but I don't have any of the source code to see for myself.. Hope this helps! --PerspX

      "Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates

      T 1 Reply Last reply
      0
      • P Perspx

        Sorry if this is pretty unhelpful :sigh: but you could (and this would be PRETTY laborious) open a file stream and write data to it when certain tasks are performed in the DLL and also (if you can) write a message to the file when the DLL exits to determine what has happened.. I'm pretty sure it's not a memory buffer overload.. This would result in the application crashing, not just exiting.. However I'm not certain so a memory issue could be the problem. Sorry I can't be of more help, but I don't have any of the source code to see for myself.. Hope this helps! --PerspX

        "Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates

        T Offline
        T Offline
        TBC_DEV
        wrote on last edited by
        #3

        Thanks PerspX for the quick reply. That's what I needed to hear. I thought maybe I was missing another obvious cause of this symptom. File logging was a last resort. It's a fairly complicated dll with only a few public functions. Sorry I can't post any code, but I'm not permitted. TBC

        P 1 Reply Last reply
        0
        • T TBC_DEV

          Thanks PerspX for the quick reply. That's what I needed to hear. I thought maybe I was missing another obvious cause of this symptom. File logging was a last resort. It's a fairly complicated dll with only a few public functions. Sorry I can't post any code, but I'm not permitted. TBC

          P Offline
          P Offline
          Perspx
          wrote on last edited by
          #4

          Yeah that's fine :) it also may help you to sort out any other bugs and even possibly make your coding more efficient :) --PerspX

          "Nowadays, security guys break the Mac every single day. Every single day, they come out with a total exploit, your machine can be taken over totally. I dare anybody to do that once a month on the Windows machine." - Bill Gates

          1 Reply Last reply
          0
          • T TBC_DEV

            I have a C++ dll (native using MFC), it is used from a few different applications. It works much of the time and has no memory issues that Purify can see. But the dll sometimes exits for no reason. No error is reported, it is not a crash or lockup. Since the Dll exits, it causes the application that uses it to exit too. Having no error reported, closing the forms, and being intermitant makes this difficult to debug. Any advise about what to look for in the code that typically causes this type of behaviour (other than forgetting to return)? Yes, the debugger could help but I have not been able to reproduce on a development PC yet. TBC

            I Offline
            I Offline
            InOut NET
            wrote on last edited by
            #5

            Are you using Threads in your DLL? Unexplainable phenomenon - The try-catch in main function did not catch exceptions in a dll's thread. The exact same *complete- and silent exit* happened to my app. It turned out that if a thread in the dll has an AccessViolation, accessing a NULL-element on a primitive-type array or other dangling reference problem, the exception catch of the host-app do not catch the execption in the dll's thread. I think you should evaluate all array accessing routines and life-span of objects and its pointer contexts. -Or implement a errorlog. But I think by the time you find the faulty pointer or array, you well could've implemented a errorlog. You should take this problem as a wake-up call for *your code is too complicated*. Debugging Spaghetti is not fun and a errorlog would help. Hope this helps.

            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