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. code in constructors [modified]

code in constructors [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++debuggingannouncement
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.
  • R Offline
    R Offline
    RedSonja
    wrote on last edited by
    #1

    I get an access violation in release mode but not in debug. Yes, I know it's been talked about in many threads and I think I have read all of them. I can even debug release mode now, to impress my colleagues. It dies when I hop into a dll I wrote, but not always quite in the same place. I have a feeling I have a NULL pointer. Anyway, I have been looking at ways I might be making a null pointer, and have made many improvements, but it still crashes. HERE is the question... One of the threads here asked if the poster had code in his constructor. Now I often have code in my constructors, I even call other constructors, with new (and I delete every single one, I promise), and as far as I am concerned this is quite normal and acceptable. Am I wrong? Could this be it? I also put code in destructors, deleting stuff and ending other processes.

    ------------- Ave computer! Hackitura te salutat! (I just made this up. Just to show you can hack Latin as well as C++.)

    modified on Monday, May 18, 2009 9:26 AM

    _ R 2 Replies Last reply
    0
    • R RedSonja

      I get an access violation in release mode but not in debug. Yes, I know it's been talked about in many threads and I think I have read all of them. I can even debug release mode now, to impress my colleagues. It dies when I hop into a dll I wrote, but not always quite in the same place. I have a feeling I have a NULL pointer. Anyway, I have been looking at ways I might be making a null pointer, and have made many improvements, but it still crashes. HERE is the question... One of the threads here asked if the poster had code in his constructor. Now I often have code in my constructors, I even call other constructors, with new (and I delete every single one, I promise), and as far as I am concerned this is quite normal and acceptable. Am I wrong? Could this be it? I also put code in destructors, deleting stuff and ending other processes.

      ------------- Ave computer! Hackitura te salutat! (I just made this up. Just to show you can hack Latin as well as C++.)

      modified on Monday, May 18, 2009 9:26 AM

      _ Offline
      _ Offline
      _AnsHUMAN_
      wrote on last edited by
      #2

      RedSonja wrote:

      I think I have read all of them

      I bet you missed this[^] one.

      You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

      R 1 Reply Last reply
      0
      • _ _AnsHUMAN_

        RedSonja wrote:

        I think I have read all of them

        I bet you missed this[^] one.

        You need to google first, if you have "It's urgent please" mentioned in your question. ;-)_AnShUmAn_

        R Offline
        R Offline
        RedSonja
        wrote on last edited by
        #3

        No I didn't. That is one of the best ones so far. (I even bookmarked it.)

        ------------- Ave computer! Hackitura te salutat! (I just made this up. Just to show you can hack Latin as well as C++.)

        1 Reply Last reply
        0
        • R RedSonja

          I get an access violation in release mode but not in debug. Yes, I know it's been talked about in many threads and I think I have read all of them. I can even debug release mode now, to impress my colleagues. It dies when I hop into a dll I wrote, but not always quite in the same place. I have a feeling I have a NULL pointer. Anyway, I have been looking at ways I might be making a null pointer, and have made many improvements, but it still crashes. HERE is the question... One of the threads here asked if the poster had code in his constructor. Now I often have code in my constructors, I even call other constructors, with new (and I delete every single one, I promise), and as far as I am concerned this is quite normal and acceptable. Am I wrong? Could this be it? I also put code in destructors, deleting stuff and ending other processes.

          ------------- Ave computer! Hackitura te salutat! (I just made this up. Just to show you can hack Latin as well as C++.)

          modified on Monday, May 18, 2009 9:26 AM

          R Offline
          R Offline
          Rajesh R Subramanian
          wrote on last edited by
          #4

          I see you have already read Joe's article on surviving the release build. By now, you must be ready to survive the release build, then. :)

          RedSonja wrote:

          and have made many improvements, but it still crashes.

          Which implies that the "many improvements" you made were not to the code which was causing the crash. A crude and quick approach would be to add OutputDebugString()[^] statements in the pieces of code that you suspect. This way, you may know until where the control reaches and where does it crash.

          It is a crappy thing, but it's life -^ Carlo Pallini

          R 1 Reply Last reply
          0
          • R Rajesh R Subramanian

            I see you have already read Joe's article on surviving the release build. By now, you must be ready to survive the release build, then. :)

            RedSonja wrote:

            and have made many improvements, but it still crashes.

            Which implies that the "many improvements" you made were not to the code which was causing the crash. A crude and quick approach would be to add OutputDebugString()[^] statements in the pieces of code that you suspect. This way, you may know until where the control reaches and where does it crash.

            It is a crappy thing, but it's life -^ Carlo Pallini

            R Offline
            R Offline
            RedSonja
            wrote on last edited by
            #5

            Thank you. I do know where it crashes, it enters my little dll through an exported function, then instantiates the class in there, and dies in the constructor, right on the {. I can tell that its problem is a null or corrupted pointer, because the debugger lets me look at the assembly code, and it tries to jump to places it's not allowed to, an access violation, as it says. I am trying to get DevPartner to run again. (The newest version seems to be a bit buggy.) When it was running before, it complained about "Calling Virtual Functions from Constructors and Destructors" and stuff like that, which I have stopped doing (this is what I meant by improvements). Hence my question. Is it OK to put code - I mean, real code that does things - in the constructor and destructor, when the compiler allows it and DevPartner whinges about it? If I can't get it running this week I shall just have to deliver the debug version, which is not so tragic right now, but it bothers me.

            ------------- Ave computer! Hackitura te salutat! (I just made this up. Just to show you can hack Latin as well as C++.)

            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