473,230 Members | 1,618 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,230 software developers and data experts.

Unallocated memorz being freed in <iostream>?

Hello everyone!

I just debugged a pretty huge project, eliminating basically every
memory leak that would occur with the current configuration files, at
least according to the mtrace() tool from the library <mcheck.h>.

Now the very last bugs I seem to be incapable of eliminating are:
- 0x000000000061f460 Free 387310 was never alloc'd 0x2aaaab053b53
- 0x000000000061f040 Free 387311 was never alloc'd 0x2aaaab053b53

Or, if I exit from the main function right after startig mtrace (as
below), those become Free 2 and Free 3.

#include <iostream>
#include <mcheck.h>

int main (int argc, char** argv) {
mtrace();
exit(0);
}

If I compile that program with g++ -o a.out a.cpp then everything runs
fine without unallocated memory freeings, however if I use my makefile
which has a bunch of sourcecode-files in it, then I get those 2
unallocated but freed pointers.
What it boiled down to was that I took .cpp-files from the makefile one
after another, in order to identify the one causing the problem.
Eventually I had one, but there is no memory freed in there unless some
code is actually called and not just #included. I commented out lines
of code and whole functions, pasted #included files directly into the
..cpp to avoid the #include, and started commenting them out. It all
ended with the only line left being #include <iostream>.
If I take that out, the program runs with no memory problems according
to mtrace(). As soon as I put it back in, the 2 unallocated but freed
pointers are back.

I am suspecting a bug in my software rather than in iostream because I
cannot reproduce this behaviour in a very small test environment. But
still, I can not exclude the possibility that there is a bug in
iostream and furthermore I have no clue on how to further try to
pinpoint the actual bug.

Any ideas?
Best Regards,
Lars

Aug 23 '06 #1
1 2093
Hello,

la**********@rwth-aachen.de wrote:
Hello everyone!

I just debugged a pretty huge project, eliminating basically every
memory leak that would occur with the current configuration files, at
least according to the mtrace() tool from the library <mcheck.h>.
This is a bit off-topic here. The particular problem only visible on GNU
platforms. I will answer, nevertheless, because similar problems might
be observable on any problem. Another memory debugging tool considered
worth looking at is valgrind. There is also purify.
>
Now the very last bugs I seem to be incapable of eliminating are:
- 0x000000000061f460 Free 387310 was never alloc'd 0x2aaaab053b53
- 0x000000000061f040 Free 387311 was never alloc'd 0x2aaaab053b53

Or, if I exit from the main function right after startig mtrace (as
below), those become Free 2 and Free 3.

#include <iostream>
#include <mcheck.h>

int main (int argc, char** argv) {
mtrace();
exit(0);
}
If mtrace turns tracing on, then allocations done before might not have
been traced, or falsely classified, if the free gets traced, but not
the allocation. This is a frequent problem with false positives by
malloc debugging facilities. The C++ streams cin, cout, ... are global
objects which are instantiated before the body of main is executed. And
they will allocate memory.
If I compile that program with g++ -o a.out a.cpp then everything runs
fine without unallocated memory freeings, however if I use my makefile
which has a bunch of sourcecode-files in it, then I get those 2
unallocated but freed pointers.
The compiler/linker might be able to remove unneccessary cin/cout
objects, if no translation unit needs it.
It all ended with the only line left being #include <iostream>.
If I take that out, the program runs with no memory problems according
to mtrace(). As soon as I put it back in, the 2 unallocated but freed
pointers are back.
IOW, More indications towards cin/cout...
>
I am suspecting a bug in my software rather than in iostream because I
cannot reproduce this behaviour in a very small test environment. But
still, I can not exclude the possibility that there is a bug in
iostream and furthermore I have no clue on how to further try to
pinpoint the actual bug.
No bug in software, but bug in user. You make mtrace produce false
positives.

Bernd Strieder

Aug 23 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: John Tiger | last post by:
Can anybody have idea about the difference between #include <iostream.h> and #include <iostream>. Is later one valid statement on any compiler. I tried compiling on MSVC second statement give...
1
by: Juergen Marsch | last post by:
Hi, writing files > 2G with standard library iostream classes results in "... file size limit exeeded." Compiling my program with "-D_FILE_OFFSET_BITS=64" doesn't make any difference. If you...
9
by: ai | last post by:
Hi , I have an application which has to read files of size few mba nd read them into array . Since i am using STL and std namespace to avoid the error error C2872: 'ifstream' : ambiguous...
4
by: aurgathor | last post by:
Howdy, What would be the equivalent of getch() using iostream? My current code is: cout << "\nPress <Enter> to continue..."; getch(); but <conio.h> is not kosher for the C++ class.
2
by: Brett | last post by:
Hi, I'm compiling an old project under the 'new' visual studio 7.1.3088. I changed the line: #include <iostream.h> to #include <iostream> and now I get a stack of errors, some of which...
9
by: nichas | last post by:
I tried to use #include<iostream> in visual C++ compiler but then it didnt work but i see this is the way it is being mentioned in C++ primer by lippman and lajoie.. where is the problem.. Do...
5
by: wesley | last post by:
Hi All. i am new to C++. I know that in order to use cout, i need to include <iostream>. I have done this, but i still get errors when i try to output to the screen. Is there a file that needs to...
1
by: Old Wolf | last post by:
In a discussion elsewhere, someone wrote: #include <iostreamis not guaranteed to define std::cout, it merely has to declare it as an extern object, and declarations of extern objects do not...
11
by: gumboots | last post by:
Hi there guys, I've recently purchased "Sam's Teach Yourself C++ Fifth Edition" (About a week before the 6th edition came out) I'm trying to work through the book, but in trying to compile Hello...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.