Bug 209886 - devel/valgrind: spurious invalid free() when using aligned_alloc()
Summary: devel/valgrind: spurious invalid free() when using aligned_alloc()
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Some People
Assignee: Niclas Zeising
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-31 11:47 UTC by Robert Clausecker
Modified: 2019-03-10 11:46 UTC (History)
1 user (show)

See Also:
bugzilla: maintainer-feedback? (bdrewery)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Clausecker 2016-05-31 11:47:14 UTC
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():


    ==1557== Memcheck, a memory error detector
    ==1557== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
    ==1557== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
    ==1557== Command: ./a
    ==1557== 
    ==1557== Invalid free() / delete / delete[] / realloc()
    ==1557==    at 0x4C232BC: free (in /usr/local/lib/valgrind/vgpreload_memcheck-amd64-freebsd.so)
    ==1557==    by 0x4007CB: main (in /tmp/a)
    ==1557==  Address 0x5806058 is not stack'd, malloc'd or (recently) free'd
    ==1557== 
    ==1557== 
    ==1557== HEAP SUMMARY:
    ==1557==     in use at exit: 0 bytes in 0 blocks
    ==1557==   total heap usage: 0 allocs, 1 frees, 0 bytes allocated
    ==1557== 
    ==1557== All heap blocks were freed -- no leaks are possible
    ==1557== 
    ==1557== For counts of detected and suppressed errors, rerun with: -v
    ==1557== 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 occur on Linux,
I suspect it comes from the interaction between jemalloc(3) and valgrind.
Comment 1 Walter Schwarzenfeld freebsd_triage 2018-01-14 01:22:29 UTC
Maintainer feedback?
Comment 2 Walter Schwarzenfeld freebsd_triage 2018-03-07 16:27:16 UTC
see also Bug #220943.
Comment 3 Walter Schwarzenfeld freebsd_triage 2019-03-09 08:36:07 UTC
Maintainership dropped ports r495096.
Comment 4 Walter Schwarzenfeld freebsd_triage 2019-03-10 11:46:23 UTC
Assign to new maintainer.