#598625 valgrind: stack frame lifetime

Package:
valgrind
Source:
valgrind
Description:
instrumentation framework for building dynamic analysis tools
Submitter:
Simon Richter
Date:
2010-09-30 14:21:04 UTC
Severity:
wishlist
#598625#5
Date:
2010-09-30 14:11:43 UTC
From:
To:
Hi,

while debugging a particularly tricky problem, I started wondering
whether it would make sense to have an option that would display whether
two stack traces shown for the same error (e.g. one that is triggered by
a double free(), and the trace for the original free() invocation) are
the same instance of the call chain, or just happen to have the same
chain repeatedly.

so:

void my_free(void *p)
{
    free(p);
}

int main(void)
{
    void *p = malloc(5);
    for(unsigned int i = 0; i < 2; ++i)
        my_free(p);
}

The stack trace would probably look like this:

Invalid free() ...
    free() at 0x12345678
    my_free() at 0x11223344
    main() at 0x22334455
.... block of size ... freed ...
    free() at 0x12345678
    my_free() at 0x11223344
    main() at 0x22334455
twice, rather than my_free calling free() multiple times. I'd be
interested in the information that the free() and my_free() stack frames
were freed inbetween, while main()s stack frame remained.

   Simon