Bug 124418

Summary: user-allocated stack is inaccessible even after thread finishes
Product: [Developer tools] valgrind Reporter: Aleksander Salwa <A.Salwa>
Component: memcheckAssignee: Julian Seward <jseward>
Status: REPORTED ---    
Severity: normal    
Priority: NOR    
Version: 3.1.1   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: test case

Description Aleksander Salwa 2006-03-28 14:25:50 UTC
User-allocated stack is inaccessible after thread finishes.
It is correct to reuse this memory (maybe allocated via malloc()) for any other
purpose. But memcheck reports errors.
Short test program is attached. memcheck complains about line with memset().

As Tom Hughes already noted on valgrind-developers list it is not easy to
handle, because Valgrind marks stack frames as (in)accessible whenever stack
pointer changes.
Maybe it is possible to remember original state of memory guessed to be client
stack ? On thread exit VG could set original state of this memory back. It is
hard for user-allocated stacks with unknown size. But not impossible - VG can
store original state gradually - each time stack expands.
Comment 1 Aleksander Salwa 2006-03-28 14:26:45 UTC
Created attachment 15333 [details]
test case
Comment 2 Aleksander Salwa 2006-03-28 15:04:20 UTC
Resetting state of whole malloc'ed block that contains this stack isn't a good solution. Proper solution should also handle stacks that are made of part of malloc'ed block or are statically allocated.
Comment 3 Julian Seward 2006-03-28 15:08:36 UTC
Realistically I think the prospects for fixing this are not good, since
we don't know how to make our stack-tracking heuristics sophisticated
enough.