I am having trouble getting Access Violation errors when I try to manipulate an array of object pointers.
I am trying to maintain an array of object pointers as a member of a class. I want to access the objects in the array in many different member methods in the class. I have a method specifically for initializing the elements in the array as necessary:
No one knows what the values of those variables you're using are. We don't know when, where, and how those functions are called, or what context they're called in, etc..
Runtime errors involving memory handling requires us to have the code, compile it ourselves, and run it with the data that you're using. Otherwise, the only thing that anyone can tell you is to check your indices and memory overwrites.
qc::Message m = localAppQueues[localQueueCount]->get();
Is it possible that I am changing the pointer by passing it into the createLocalQueue method? It appears to me that moving the method's inline does not change anything.
To compile and run this would take more time than I would expect anyone to spend on it.
The point is that runtime errors cannot be debugged by individuals looking at two or three lines of code from a much larger program. Add to that, no knowledge of the values of those variables or in what state your program is in by the time it reaches the crash point. We also don't know what those functions you're calling are doing internally.
But maybe I can narrow it down. When I do not pass the pointer to the createLocalQueue method, I am able to use it without the Access Violation
Your errors could have occurred much sooner than the code you're looking at. That code is where the application finally breaks down, but it doesn't guarantee that is the origin of the error.
Is it possible that I am changing the pointer by passing it into the createLocalQueue method? It appears to me that moving the method's inline does not change anything.
You cannot "change the pointer" unless you pass a pointer to the pointer you're changing. You are not doing that.
Secondly, trying random things here and there is not how you solve these issues. You have to know why something doesn't work, and then fix it. Otherwise, what you'll end up doing is changing the code around so much that the error is moved to another part of the code, maybe a part of the code that isn't executed, giving a false sense that the problem is fixed.
Regards,
Paul McKenzie
Last edited by Paul McKenzie; January 6th, 2010 at 11:32 AM.
My apologies, in the previous post I had reversed the code segments. The first throws an error and the second (without the method call) is successful.
First of all, please use code tags when posting code.
The difference between the two pieces of code you posted seems to be the scope of the 'subs' variable. In the former, it is destroyed when exiting the function createLocalQueue, whereas in the latter it is destroyed later. That could give you a hint at where to look... or it could be incidental.
As Paul explained, with the information you have provided it's more of a guessing game than anything else.
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
Bookmarks