From owner-freebsd-stable@FreeBSD.ORG Fri Mar 16 11:23:51 2012 Return-Path: Delivered-To: freebsd-stable@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 27C8A106579C for ; Fri, 16 Mar 2012 11:23:51 +0000 (UTC) (envelope-from inarvaj@gmail.com) Received: from mail-lpp01m010-f54.google.com (mail-lpp01m010-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 00D0A8FC12 for ; Fri, 16 Mar 2012 11:23:49 +0000 (UTC) Received: by lagv3 with SMTP id v3so4406091lag.13 for ; Fri, 16 Mar 2012 04:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=VvawuRhCeevMghud/w4MKraPxjXhAVoH+N/I/6IEfBU=; b=oqtxquMr0dNxB0fuEcxW6J5FYEsivyXzsvWFJrhY267G5wBoNcuKjbyGAvG1qrmRyO TwHt2JseX370kfeqB5AJADep/UPMs47IGKKdtzZ9Wt+9RNC0yhS9muE5puebfa7NDhWh qq6xrSTuGJxUfaIToJ21te1t+4C0xlGkDCNEAVFWpNcM//k8AbZLDu4nMhlxP/MuXFjO zzPaRbIbOkZ1SXg8bzyEW310jJZ28TZsJScWShOSarhOhQq5WT5bqxaNOE0ULL85Oues r7j3GV9/Yt623UAb0B+hJR/DczLmiNLmtQsG+8FL++LoetdEN1g3NXkGsq3PHl4wgCO0 jWQg== MIME-Version: 1.0 Received: by 10.152.132.104 with SMTP id ot8mr1646036lab.17.1331897028878; Fri, 16 Mar 2012 04:23:48 -0700 (PDT) Received: by 10.152.4.103 with HTTP; Fri, 16 Mar 2012 04:23:48 -0700 (PDT) Date: Fri, 16 Mar 2012 13:23:48 +0200 Message-ID: From: "Ina J." To: freebsd-stable@FreeBSD.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: FreeBSD 9.0: Valgrind leaks memory X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Mar 2012 11:23:51 -0000 Hi, I tried to find a thread about this, but I didn't and in this threadtrasz suggested to send message to the mailing list. I've been developing program for Linux under Ubuntu 10.04. I want to get the code running under my FreeBSD 9.0-RELEASE server. The code compiles without problems, but Valgrind doesn't work the same way as on my Ubuntu. I made an example code, which produces a memory leak with Valgrind. The code is as follows: ### C O D E ### #include int main() { std::cout << "Valgrind leaks memory" << std::endl; return 0; } I compile it simply with command: g++ test.cc And then run it in valgrind: valgrind --show-reachable=yes --tool=memcheck --db-attach=yes --leak-check=full --track-origins=yes ./a.out And Valgrind outputs this: ### V AL G R I N D O U T P U T ### ==39783== Memcheck, a memory error detector ==39783== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al. ==39783== Using Valgrind-3.6.1 and LibVEX; rerun with -h for copyright info ==39783== Command: ./a.out ==39783== Valgrind leaks memory ==39783== ==39783== HEAP SUMMARY: ==39783== in use at exit: 4,096 bytes in 1 blocks ==39783== total heap usage: 1 allocs, 0 frees, 4,096 bytes allocated ==39783== ==39783== 4,096 bytes in 1 blocks are still reachable in loss record 1 of 1 ==39783== at 0x5BF98: malloc (in /usr/local/lib/valgrind/vgpreload_memcheck-x86-freebsd.so) ==39783== by 0x26B503: ??? (in /lib/libc.so.7) ==39783== by 0x26B3C4: ??? (in /lib/libc.so.7) ==39783== by 0x26AF12: ??? (in /lib/libc.so.7) ==39783== by 0x26AAB4: fwrite (in /lib/libc.so.7) ==39783== by 0xA1135: ??? (in /usr/lib/libstdc++.so.6) ==39783== by 0xDC3C7: std::basic_ostream >& std::__ostream_insert >(std::basic_ostream >&, char const*, int) (in /usr/lib/libstdc++.so.6) ==39783== by 0xDC5DB: std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*) (in /usr/lib/libstdc++.so.6) ==39783== by 0x80488C4: main (in /usr/home/ina/test/a.out) ==39783== ==39783== LEAK SUMMARY: ==39783== definitely lost: 0 bytes in 0 blocks ==39783== indirectly lost: 0 bytes in 0 blocks ==39783== possibly lost: 0 bytes in 0 blocks ==39783== still reachable: 4,096 bytes in 1 blocks ==39783== suppressed: 0 bytes in 0 blocks ==39783== ==39783== For counts of detected and suppressed errors, rerun with: -v ==39783== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) In my Ubuntu, Valgrind detects no memory leaks. Although, those reported leaks are just reachable bytes, but there shouldn't be any of them. On my Ubuntu g++ and Valgrind versions are as follows: g++ (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3 valgrind-3.6.0.SVN-Debian And on FreeBSD: g++ (GCC) 4.2.1 20070831 patched [FreeBSD] valgrind-3.6.1 With my actual code, Valgrind reports a lot more memory leaks and also those mentioned on the thread I linked, but sample code is enough to produce errors which shouldn't exist. -Ina