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