public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/12831] New: mtrace location not usefull for C++
@ 2011-06-01 8:28 yair.lenga at citi dot com
2011-06-01 8:30 ` [Bug libc/12831] mtrace location not useful " yair.lenga at citi dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: yair.lenga at citi dot com @ 2011-06-01 8:28 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=12831
Summary: mtrace location not usefull for C++
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper.fsp@gmail.com
ReportedBy: yair.lenga@citi.com
Summary:
The address reported by mtrace for C++ program is the location of the new
operators, and not the name of the calling program.
Long Description:
I've been working with mtrace output for the last few days to resolve a complex
memory management bug in C++ program. While the mtrace output provides
essential information, the address field is provided with each line is useless,
as it points to the new operators inside the c++ runtime library.
The correct/better behavior is to retrieve the address of the calling program
for the c++ new operators (using backtrace-like function), and using it in the
trace output file. This could be done whenever the address resolve to
"/usr/lib/libstdc++.so.6:(_Znwj+0x27)[0x258bb7]" address.
More general solution will allow specifying allowing user-defined env var to
control list of ".so", which should be ignored.
Even better solution will include addresses from multiple frames of the
backtrace, which will make it easier to capture the calling stack of the code
during the memory allocation.
In theory, all of those can be done using the malloc hooks. However,
implementing the hooks is very hard for most users. Implementing the proposed
solution in glibc will make the mtrace function significantly more valuable for
c++ developers.
Example:
consider the following C++ memory leaking program (complete source below). The
output is:
Memory not freed:
-----------------
Address Size Caller
0x084d9378 0x186a0 at prog.cc:11
0x084f1a20 0x2710 at prog.cc:12
0xb755a008 0xf4240 at 0x258bb7
0xb764f008 0xf4240 at 0x258bb7
The location of the malloc/calloc calls is resolved to line number. However,
all the "new" calls do not show the correct line number.
Complete example:
g++ -g prog.cc
export MALLOC_TRACE=trace.txt
./a.out
cat trace.txt
mtrace a.out trace.txt
Program: prog.cc
#include <mcheck.h>
#include <stdlib.h>
class T1 { char c[10000] ; } ;
int f(void)
{
mtrace() ;
static T1 *x = new T1[100] ;
static T1 *u = new T1[100] ;
static T1 *y = (T1 *)calloc(10, sizeof(T1)) ;
static T1 *z = (T1 *)malloc(sizeof(T1)) ;
}
int main(void)
{
f();
}
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/12831] mtrace location not useful for C++
2011-06-01 8:28 [Bug libc/12831] New: mtrace location not usefull for C++ yair.lenga at citi dot com
@ 2011-06-01 8:30 ` yair.lenga at citi dot com
2011-06-01 11:18 ` drepper.fsp at gmail dot com
2014-06-27 13:14 ` fweimer at redhat dot com
2 siblings, 0 replies; 4+ messages in thread
From: yair.lenga at citi dot com @ 2011-06-01 8:30 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=12831
yair <yair.lenga at citi dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|mtrace location not usefull |mtrace location not useful
|for C++ |for C++
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/12831] mtrace location not useful for C++
2011-06-01 8:28 [Bug libc/12831] New: mtrace location not usefull for C++ yair.lenga at citi dot com
2011-06-01 8:30 ` [Bug libc/12831] mtrace location not useful " yair.lenga at citi dot com
@ 2011-06-01 11:18 ` drepper.fsp at gmail dot com
2014-06-27 13:14 ` fweimer at redhat dot com
2 siblings, 0 replies; 4+ messages in thread
From: drepper.fsp at gmail dot com @ 2011-06-01 11:18 UTC (permalink / raw)
To: glibc-bugs
http://sourceware.org/bugzilla/show_bug.cgi?id=12831
Ulrich Drepper <drepper.fsp at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |WONTFIX
--- Comment #1 from Ulrich Drepper <drepper.fsp at gmail dot com> 2011-06-01 11:17:59 UTC ---
Then don't use mtrace. It never was designed for these types of things.
--
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug libc/12831] mtrace location not useful for C++
2011-06-01 8:28 [Bug libc/12831] New: mtrace location not usefull for C++ yair.lenga at citi dot com
2011-06-01 8:30 ` [Bug libc/12831] mtrace location not useful " yair.lenga at citi dot com
2011-06-01 11:18 ` drepper.fsp at gmail dot com
@ 2014-06-27 13:14 ` fweimer at redhat dot com
2 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2014-06-27 13:14 UTC (permalink / raw)
To: glibc-bugs
https://sourceware.org/bugzilla/show_bug.cgi?id=12831
Florian Weimer <fweimer at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Flags| |security-
--
You are receiving this mail because:
You are on the CC list for the bug.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-06-27 13:14 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-01 8:28 [Bug libc/12831] New: mtrace location not usefull for C++ yair.lenga at citi dot com
2011-06-01 8:30 ` [Bug libc/12831] mtrace location not useful " yair.lenga at citi dot com
2011-06-01 11:18 ` drepper.fsp at gmail dot com
2014-06-27 13:14 ` fweimer at redhat dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).