From owner-freebsd-ports-bugs@freebsd.org Wed Oct 14 14:59:57 2020 Return-Path: Delivered-To: freebsd-ports-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6AD8043B476 for ; Wed, 14 Oct 2020 14:59:57 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (mailman.nyi.freebsd.org [IPv6:2610:1c1:1:606c::50:13]) by mx1.freebsd.org (Postfix) with ESMTP id 4CBFvK2FQKz45pW for ; Wed, 14 Oct 2020 14:59:57 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 4D13343B475; Wed, 14 Oct 2020 14:59:57 +0000 (UTC) Delivered-To: ports-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 4CD9343B63C for ; Wed, 14 Oct 2020 14:59:57 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CBFvK1Lxfz45rb for ; Wed, 14 Oct 2020 14:59:57 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 12AE5103C3 for ; Wed, 14 Oct 2020 14:59:57 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 09EExusu053063 for ; Wed, 14 Oct 2020 14:59:56 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 09EExuV6053062 for ports-bugs@FreeBSD.org; Wed, 14 Oct 2020 14:59:56 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: ports-bugs@FreeBSD.org Subject: [Bug 250345] devel/valgrind: 3.17.0-GIT valgrind not picking up right malloc on override Date: Wed, 14 Oct 2020 14:59:56 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Ports & Packages X-Bugzilla-Component: Individual Port(s) X-Bugzilla-Version: Latest X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: karnajitw@gmail.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: zeising@FreeBSD.org X-Bugzilla-Flags: maintainer-feedback? X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter flagtypes.name Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Oct 2020 14:59:57 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D250345 Bug ID: 250345 Summary: devel/valgrind: 3.17.0-GIT valgrind not picking up right malloc on override Product: Ports & Packages Version: Latest Hardware: amd64 OS: Any Status: New Severity: Affects Some People Priority: --- Component: Individual Port(s) Assignee: zeising@FreeBSD.org Reporter: karnajitw@gmail.com Assignee: zeising@FreeBSD.org Flags: maintainer-feedback?(zeising@FreeBSD.org) Below is an example where I am calling __malloc from my own malloc function. #include #include #include #include void *__malloc(unsigned long); void __free(void *); void *malloc(size_t sz) { void *ptr =3D NULL; size_t origsz =3D sz + 4; ptr =3D __malloc(origsz); *((int *)ptr) =3D sz; write(1, "malloc called\n", 14); return ptr + 4; } void myfree(void *ptr) { void *orig_ptr =3D ptr - 4; write(1, "free called\n", 12); __free(orig_ptr); } int main() { char *str1 =3D (char *)malloc(100); memcpy(str1, "Hello World", 12); myfree(str1); return 0; } Without valgrind the result looks like this # ./a.out malloc called free called With valgrind its like this # valgrind ./a.out =3D=3D14188=3D=3D Memcheck, a memory error detector =3D=3D14188=3D=3D Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward = et al. =3D=3D14188=3D=3D Using Valgrind-3.17.0.GIT and LibVEX; rerun with -h for c= opyright info =3D=3D14188=3D=3D Command: ./a.out =3D=3D14188=3D=3D =3D=3D14188=3D=3D Warning: set address range perms: large range [0x7fffdfff= f000, 0x7ffffffdf000) (noaccess) free called =3D=3D14188=3D=3D Invalid free() / delete / delete[] / realloc() =3D=3D14188=3D=3D at 0x485068E: free (src/paul-floyd-317-fbsd12/valgrind-freebsd/coregrind/m_replacemalloc/vg_re= place_malloc.c:611) =3D=3D14188=3D=3D by 0x20162F: myfree (malloc_free.c:23) =3D=3D14188=3D=3D by 0x20167E: main (malloc_free.c:30) =3D=3D14188=3D=3D Address 0x540003c is 4 bytes before a block of size 100 = alloc'd =3D=3D14188=3D=3D at 0x484F4B9: malloc (src/paul-floyd-317-fbsd12/valgrind-freebsd/coregrind/m_replacemalloc/vg_re= place_malloc.c:312) =3D=3D14188=3D=3D by 0x201658: main (malloc_free.c:28) =3D=3D14188=3D=3D =3D=3D14188=3D=3D =3D=3D14188=3D=3D HEAP SUMMARY: =3D=3D14188=3D=3D in use at exit: 100 bytes in 1 blocks =3D=3D14188=3D=3D total heap usage: 1 allocs, 1 frees, 100 bytes allocated =3D=3D14188=3D=3D =3D=3D14188=3D=3D LEAK SUMMARY: =3D=3D14188=3D=3D definitely lost: 100 bytes in 1 blocks =3D=3D14188=3D=3D indirectly lost: 0 bytes in 0 blocks =3D=3D14188=3D=3D possibly lost: 0 bytes in 0 blocks =3D=3D14188=3D=3D still reachable: 0 bytes in 0 blocks =3D=3D14188=3D=3D suppressed: 0 bytes in 0 blocks =3D=3D14188=3D=3D Rerun with --leak-check=3Dfull to see details of leaked m= emory =3D=3D14188=3D=3D =3D=3D14188=3D=3D For lists of detected and suppressed errors, rerun with: = -s =3D=3D14188=3D=3D ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 fr= om 0) Only myfree is called in valgrind env and additional invalid free error cam= e as a result of this. Please verify. overriding reallocf doesn't have this issue under valgrind. --=20 You are receiving this mail because: You are the assignee for the bug.=