ports/99070: ccmalloc: no backtraces on amd64 when compiled with -O
Matt
freebsdbugs at fjarlq.com
Sat Jun 17 06:20:16 UTC 2006
>Number: 99070
>Category: ports
>Synopsis: ccmalloc: no backtraces on amd64 when compiled with -O
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Jun 17 06:20:14 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:
>Release: FreeBSD 6.1-RELEASE
>Organization:
>Environment:
Platform: amd64
% gcc -v
Using built-in specs.
Configured with: FreeBSD/amd64 system compiler
Thread model: posix
gcc version 3.4.4 [FreeBSD] 20050518
>Description:
When compiled with the -O optimization flag on the amd64 platform,
devel/ccmalloc version 0.4.0 does not generate backtraces in its
memory leak reports. The reports are created, but the helpful
backtraces are missing.
On i386 I could not reproduce this problem, ccmalloc on that platform
works fine when compiled with -O.
>How-To-Repeat:
1) Add the -O option to CFLAGS in /etc/make.conf.
The exact line I had was:
CFLAGS= -O -pipe
I've built everything on my system, including hundreds of packages,
with this setting without any problem until now.
2) Build and install devel/ccmalloc from ports.
3) Build a test program using ccmalloc:
% cat > testmalloc.c
char *addr;
leak() { addr = malloc(4096); }
call() { leak(); }
main() { call(); }
^D
% ccmalloc cc -g testmalloc.c -o testmalloc
4) Run the testmalloc program you built; a report with a valid
summary will be generated, but the backtrace of the malloc caller
will be missing:
% testmalloc
file-name=a.out does not contain valid symbols
trying to find executable in current directory ...
(to speed up this search specify `file testmalloc'
in the startup file `.ccmalloc (but not found)')
.--------------------------------------------------------------------------.
|================ ccmalloc-0.4.0 (C) 1997-2003 Armin Biere ================|
+--------------------------------------------------------------------------+
| executable = testmalloc |
| startup file = .ccmalloc (but not found) |
| log file = stderr |
| start time = Fri Jun 16 23:03:22 2006 |
| operating system = FreeBSD 6.1-RELEASE amd64 on example.com |
+--------------------------------------------------------------------------+
| only-count = 0 keep-deallocated-data = 0 |
| check-interval = 0 check-free-space = 0 |
| check-start = 0 file-info = 1 |
| chain-length = 0 additional-line = 1 |
| check-underwrites = 0 print-addresses = 0 |
| check-overwrites = 0 print-on-one-line = 0 |
| sort-by-wasted = 1 sort-by-size = 1 |
| # only-log-chain = 0 continue = 0 |
| # dont-log-chain = 0 statistics = 0 |
| debug = 0 library-chains = 0 |
| load-dynlibs = 0 align-8-byte = 0 |
| only-wasting-alloc= 1 |
`--------------------------------------------------------------------------'
.---------------.
|ccmalloc report|
=======================================================
| total # of| allocated | deallocated | garbage |
+-----------+-------------+-------------+-------------+
| bytes| 4096 | 0 | 4096 |
+-----------+-------------+-------------+-------------+
|allocations| 1 | 0 | 1 |
+-----------------------------------------------------+
| number of checks: 1 |
| number of counts: 1 |
| retrieving function names for addresses ... done. |
| reading file info from gdb ... done. |
| sorting by number of not reclaimed bytes ... done. |
| number of call chains: 0 |
| number of ignored call chains: 0 |
| number of reported call chains: 0 |
| number of internal call chains: 0 |
| number of library call chains: 1 |
`------------------------------------------------------
>Fix:
I added this to my /etc/make.conf to override CFLAGS for devel/ccmalloc:
.if ${.CURDIR:M*/devel/ccmalloc}
CFLAGS= -pipe
.endif
Reinstall devel/ccmalloc, rebuild your test program, and it should
generate a backtrace in the report now:
% testmalloc
file-name=a.out does not contain valid symbols
trying to find executable in current directory ...
(to speed up this search specify `file testmalloc'
in the startup file `.ccmalloc (but not found)')
.--------------------------------------------------------------------------.
|================ ccmalloc-0.4.0 (C) 1997-2003 Armin Biere ================|
+--------------------------------------------------------------------------+
| executable = testmalloc |
| startup file = .ccmalloc (but not found) |
| log file = stderr |
| start time = Fri Jun 16 23:09:17 2006 |
| operating system = FreeBSD 6.1-RELEASE amd64 on example.com |
+--------------------------------------------------------------------------+
| only-count = 0 keep-deallocated-data = 0 |
| check-interval = 0 check-free-space = 0 |
| check-start = 0 file-info = 1 |
| chain-length = 0 additional-line = 1 |
| check-underwrites = 0 print-addresses = 0 |
| check-overwrites = 0 print-on-one-line = 0 |
| sort-by-wasted = 1 sort-by-size = 1 |
| # only-log-chain = 0 continue = 0 |
| # dont-log-chain = 0 statistics = 0 |
| debug = 0 library-chains = 0 |
| load-dynlibs = 0 align-8-byte = 0 |
| only-wasting-alloc= 1 |
`--------------------------------------------------------------------------'
.---------------.
|ccmalloc report|
=======================================================
| total # of| allocated | deallocated | garbage |
+-----------+-------------+-------------+-------------+
| bytes| 4096 | 0 | 4096 |
+-----------+-------------+-------------+-------------+
|allocations| 1 | 0 | 1 |
+-----------------------------------------------------+
| number of checks: 1 |
| number of counts: 1 |
| retrieving function names for addresses ... done. |
| reading file info from gdb ... done. |
| sorting by number of not reclaimed bytes ... done. |
| number of call chains: 1 |
| number of ignored call chains: 0 |
| number of reported call chains: 1 |
| number of internal call chains: 1 |
| number of library call chains: 0 |
=======================================================
|
*100.0% = 4096 Bytes of garbage allocated in 1 allocation
| |
| | 0x0040162e in <main>
| | at testmalloc.c:4
| |
| | 0x0040161e in <call>
| | at testmalloc.c:3
| |
| | 0x004015fe in <leak>
| | at testmalloc.c:2
| |
| `-----> 0x0040193e in <malloc>
|
`------------------------------------------------------
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list