Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 May 2016 11:47:14 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-ports-bugs@FreeBSD.org
Subject:   [Bug 209886] devel/valgrind: spurious invalid free() when using aligned_alloc()
Message-ID:  <bug-209886-13@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D209886

            Bug ID: 209886
           Summary: devel/valgrind: spurious invalid free() when using
                    aligned_alloc()
           Product: Ports & Packages
           Version: Latest
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: Individual Port(s)
          Assignee: bdrewery@FreeBSD.org
          Reporter: fuz@fuz.su
          Assignee: bdrewery@FreeBSD.org
             Flags: maintainer-feedback?(bdrewery@FreeBSD.org)

The simple program

    #include <stdlib.h>

    int main()
    {
            free(aligned_alloc(8, 8));
            return (0);
    }

causes valgrind(1) to complain about a spurious invalid free():


    =3D=3D1557=3D=3D Memcheck, a memory error detector
    =3D=3D1557=3D=3D Copyright (C) 2002-2013, and GNU GPL'd, by Julian Sewa=
rd et al.
    =3D=3D1557=3D=3D Using Valgrind-3.10.1 and LibVEX; rerun with -h for co=
pyright info
    =3D=3D1557=3D=3D Command: ./a
    =3D=3D1557=3D=3D=20
    =3D=3D1557=3D=3D Invalid free() / delete / delete[] / realloc()
    =3D=3D1557=3D=3D    at 0x4C232BC: free (in
/usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
    =3D=3D1557=3D=3D    by 0x4007CB: main (in /tmp/a)
    =3D=3D1557=3D=3D  Address 0x5806058 is not stack'd, malloc'd or (recent=
ly) free'd
    =3D=3D1557=3D=3D=20
    =3D=3D1557=3D=3D=20
    =3D=3D1557=3D=3D HEAP SUMMARY:
    =3D=3D1557=3D=3D     in use at exit: 0 bytes in 0 blocks
    =3D=3D1557=3D=3D   total heap usage: 0 allocs, 1 frees, 0 bytes allocat=
ed
    =3D=3D1557=3D=3D=20
    =3D=3D1557=3D=3D All heap blocks were freed -- no leaks are possible
    =3D=3D1557=3D=3D=20
    =3D=3D1557=3D=3D For counts of detected and suppressed errors, rerun wi=
th: -v
    =3D=3D1557=3D=3D ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0=
 from 0)

I suspect that valgrind doesn't properly intercept aligned_alloc(3) and thus
doesn't
recognize the address when it is passed to free(). This issue does not occu=
r on
Linux,
I suspect it comes from the interaction between jemalloc(3) and valgrind.

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-209886-13>