This is the mail archive of the systemtap@sourceware.org mailing list for the systemtap project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC updated PATCH 1/2] Bug Translator 3016 : Error accessing members of anonymous structs / unions


Hi Prerna,

Prerna Saxena wrote:
> Hi all,
> I'm posting patch 1 of 2 after fixing a bug which was causing it to fail 
> on x86_64.
> 
> @Masami,  thanks for pointing me to it :-)
> 
> Masami Hiramatsu wrote:
>> I think below code is a suspicious code.
>>
>>   
>>> +                   Dwarf_Die *result_die = translate_components(pool, tail,
>>> pc, components, &temp_die, &temp_die, &temp_attr );
>>>     
>> Since temp_die is just a local variable, I think secound &temp_die(6th argument)
>> should be die_mem as same as original function.

As far as I can see, your patch still use a local variable for returning
memory buffer(temp_die_2).

> +		   Dwarf_Die temp_die_2;
[snip]
> +                   Dwarf_Die *result_die = translate_components(pool, tail, pc, components, &temp_die, &temp_die_2, &temp_attr );
> +

If translate_components found a matched die, it stores that die information into
die_mem(temp_die_2, in your code) and returns the address of die_mem(&temp_die_2)
to caller.

> +		   if (result_die != NULL)
> +			{ 
> +			  *attr_mem = temp_attr;
> +			  return result_die;
> +			}

In your code, if result_die (= &temp_die_2) is not NULL, returns it to
caller again. This means, translate_components returns it's local memory
on stack which will be used by other functions in the future.
(Note: Without your patch, translate_components returns vardie or die_mem,
both of which are passed from caller and not on local memory.)

So, I think you must use die_mem which is passed by other functions(
literal_stmt_for_local or literal_stmt_for_return) instead of &temp_die_2.

Thank you,

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]