|
From: Konstantin S. <kon...@gm...> - 2009-05-18 08:11:30
|
Hello Memcheckers,
I've got a complain from a novice memcheck user about a confusing message:
% cat stack_uninit.c
int main() {
int unrelated[100];
// ...
int uninited[10];
return uninited[3] ? 1 : 0;
}
% ~/valgrind/trunk/Inst/bin/valgrind -q --track-origins=yes ./a.out
==25539== Syscall param exit_group(status) contains uninitialised byte(s)
...
==25539== Uninitialised value was created by a stack allocation
==25539== at 0x4004B0: main (stack_uninit.c:1)
The stack 'main (stack_uninit.c:1)' points to the beginning of the
function's code .
Is it possible to get the exact line where the uninitialized stack
object was created (line 4 instead of line 1)?
If this is hard or impossible, could you change the message text to
make it less confusing?
Something like: 'Uninitialised value was created by a stack allocation
at or after this point:'.
Thanks,
--kcc
|
|
From: Nicholas N. <n.n...@gm...> - 2009-05-18 22:29:39
|
On Mon, May 18, 2009 at 6:11 PM, Konstantin Serebryany
<kon...@gm...> wrote:
> Hello Memcheckers,
>
> I've got a complain from a novice memcheck user about a confusing message:
>
> % cat stack_uninit.c
> int main() {
> int unrelated[100];
> // ...
> int uninited[10];
> return uninited[3] ? 1 : 0;
> }
> % ~/valgrind/trunk/Inst/bin/valgrind -q --track-origins=yes ./a.out
> ==25539== Syscall param exit_group(status) contains uninitialised byte(s)
> ...
> ==25539== Uninitialised value was created by a stack allocation
> ==25539== at 0x4004B0: main (stack_uninit.c:1)
>
> The stack 'main (stack_uninit.c:1)' points to the beginning of the
> function's code .
> Is it possible to get the exact line where the uninitialized stack
> object was created (line 4 instead of line 1)?
>
> If this is hard or impossible, could you change the message text to
> make it less confusing?
> Something like: 'Uninitialised value was created by a stack allocation
> at or after this point:'.
I think the current behaviour is reasonable. The stack memory is
allocated upon entry to the function; if you have more than one stack
variable they will be allocated all at once, not one at a time.
Because of this, the debug info, which Valgrind relies on, identifies
the stack allocation with the opening brace of the function, which is
often on its own line but in your example is on the same line as the
declaration for main().
N
|
|
From: Konstantin S. <kon...@gm...> - 2009-05-19 08:58:48
|
On Tue, May 19, 2009 at 2:29 AM, Nicholas Nethercote
<n.n...@gm...> wrote:
> On Mon, May 18, 2009 at 6:11 PM, Konstantin Serebryany
> <kon...@gm...> wrote:
>> Hello Memcheckers,
>>
>> I've got a complain from a novice memcheck user about a confusing message:
>>
>> % cat stack_uninit.c
>> int main() {
>> int unrelated[100];
>> // ...
>> int uninited[10];
>> return uninited[3] ? 1 : 0;
>> }
>> % ~/valgrind/trunk/Inst/bin/valgrind -q --track-origins=yes ./a.out
>> ==25539== Syscall param exit_group(status) contains uninitialised byte(s)
>> ...
>> ==25539== Uninitialised value was created by a stack allocation
>> ==25539== at 0x4004B0: main (stack_uninit.c:1)
>>
>> The stack 'main (stack_uninit.c:1)' points to the beginning of the
>> function's code .
>> Is it possible to get the exact line where the uninitialized stack
>> object was created (line 4 instead of line 1)?
>>
>> If this is hard or impossible, could you change the message text to
>> make it less confusing?
>> Something like: 'Uninitialised value was created by a stack allocation
>> at or after this point:'.
>
> I think the current behaviour is reasonable. The stack memory is
> allocated upon entry to the function; if you have more than one stack
> variable they will be allocated all at once, not one at a time.
> Because of this, the debug info, which Valgrind relies on, identifies
> the stack allocation with the opening brace of the function, which is
> often on its own line but in your example is on the same line as the
> declaration for main().
That is right. But not every memcheck user understands that.
I just suggested to make the report phrase a bit more descriptive.
Thanks,
--kcc
>
> N
>
|
|
From: Nicholas N. <n.n...@gm...> - 2009-05-20 02:10:21
|
On Tue, May 19, 2009 at 6:58 PM, Konstantin Serebryany <kon...@gm...> wrote: >> I think the current behaviour is reasonable. The stack memory is >> allocated upon entry to the function; if you have more than one stack >> variable they will be allocated all at once, not one at a time. >> Because of this, the debug info, which Valgrind relies on, identifies >> the stack allocation with the opening brace of the function, which is >> often on its own line but in your example is on the same line as the >> declaration for main(). > > That is right. But not every memcheck user understands that. > I just suggested to make the report phrase a bit more descriptive. I would be reluctant to make an accurate message less accurate in order to address a user's lack of knowledge about how stack frames work. Nick |