What the heck is a corrupted double linked list???
Okay I am really really upset. I am trying to make a garbage collector in my C++ program. I've spent about a month now trying every thing I can to get around the thing about not being able to know if the instance of a class is dynamic or not, because, of course, I can't call delete on a staticly created object.
Since "powerful!" C++ doesn't give you any way of doing this, I've been using ugly macros etc.. just to try and let my garbage collector know whether or not my object is dynamicly cunstructed or not... Okay, that is only the first part. Now for the second. WHAT DOES THIS MEAN: *** glibc detected *** corrupted double-linked list: 0x00000000006d6070 ***!!???!!!?? There is no information about it on google, and the lovely debugger, of course, as always, says: "it happened somewhere, in ??? function, uuhhhh... or something...". What does this mean? Oh, and incase you wanted to know, C++ also stinks because I really just need to have the damn cunstructor of an object return ITSELF!! so it can be overridden (in case the programmer might need that... say... if the object he wants is already in another "auto-pointer" somewhere... damnit). In short I am upset because, as usual, there isn't I can't find any good information, and because C++ is contstricted when you actually want to do something powerful!!! Darn it. // edited by crabboy to remove obscenities |
Man, this is not the place to discharge your expletives. It has been reported...
|
The_Nerd: As much as I dislike doing so, your post has been cleaned up. The next time I encounter a post like this the content will not survive as it has in this instance.
|
One approach to do what you wanted is to make all constructors private. That way they can not be called directly. You then write a function that will create and return the object for you. This way you know that the object will be created dynamically.
|
Lets just see how many constructive replies you get.
Link taken from Matir's signature http://www.catb.org/~esr/faqs/smart-questions.html Quote:
|
Well, at least I got posts. I just assumed someone would delete it, and then go on their merry way. Anyhow, thanks everyone for informing me how to post... like I didn't know I was breaking rules...
In anycase, yes, I admit I was in a rage, yes I admit it was unnecessary, but it was fun. Even so, I am sorry for anyone I offended. Thanks for the posts, and again, sorry. |
So did you find the memory corruption causing this error message ?
If not, may be can you port the whole stuff to Java, and let its GC do the job for you ... |
Ahh, don't bring that four letter dirty word into the mix. C++ is a great language. Post some code.
|
Quote:
First off, I'd like to say I'm glad that someone reads my signature. I'm somewhat impressed to be referred to in a thread I have yet to post in. :) To the OP: a code sample would be good, as well as a gdb backtrace. I'd love to try to compile and run your code and see how it works, and hopefully be able to resolve this issue. |
Quote:
Quote:
Quote:
- What compiler(s) is used ? - On what architecture ? - Were free tools like Valgrind, Sun's Studio RTC or commercial ones like Purify used to debug the issue ? |
Quote:
Quote:
Guess it goes to prove we all have our own tastes. |
I'm personally rather disappointed with the fact that this thread has degenerated into a Java vs. C++ debate. There are some things that just can't be done in Java, and C++ leaves a lot up to the coder (like C) to get right. Each developer needs to determine what is right on each project. I've worked with C, C++, Java, and several other languages. I like C best, but that doesn't mean I claim it to be superior. Or does it? :)
|
Quote:
Ok then, lets look at the problem. You want a garbage collector to delete the objects. Quote:
|
doesnt boost offer some sort of garbage collection?
|
Alrighty, here is the code for the new garbage collector I've written. After my "fit", I stopped programming for a while and just thought it over. Since this garbage collector was going into my 2D engine, which was a rather big project, I decided to make the same thing in a smaller app to build/test it. So, here it is. I normally wouldn't release code like this, since my engine is proprietary, but I feel obligated for having eased my "fit" here. Also, I hope some snippets of code may prove useful to others.
Some pointers: - You may wonder why I have some very strange looking functions, and lots of static veriables. There is only one reason for this, and that is "the global scope". This garbage collector requires lists. However, I can't have those lists in the global scope, because it is very possible that the object might get created before the list... So, I use static variables in "wrapper" functions (such as DynamicList in object.cpp) to achieve what I want, with no segmentation faults. :) - I know you want to tell me really really badly about std::list, just don't! Half my problem with the old GC was std::list always causing some really really bad memory error (SEGV), and having the backtrace be about ten pages long, with half the called functions onknown... in short, std::list is impossible to debug and it is slow. I created my own list class because of this reason, and because I've never liked the std::list. I think it was designed stupid like. Not only that, though I don't have any proof, I think my list class is faster. - I don't want to use Boost!!! No other library scares me like that one. "Fear comes from misunderstanding" you say? Well, you are right. I don't understand the Boost libraries, and don't really want to. Besides that, I am already linking my 2D engine against too many libraries. - I don't case about Java. Java is cool and all, but I've started the engine in C++, and I am not gunna scrap everything now just to goto Java because of one or two benifits... uuhhhhggg Have fun trying to understand my code! Basically, to have an object tracked by the garbage collector, all you have to do is derive any class you want to track from CObjectBase<T>, where T is the class name. The "auto-pointers" aren't implemented yet, so don't spend hours looking for a reference count variable, it isn't there, yet. Remember, this is just a functioning test! Finally, here is the link to the code: http://www.restorides.com/~nerd/gc-test.tar.bz2 |
All times are GMT -5. The time now is 03:48 PM. |