|
From: Bart V. A. <bar...@gm...> - 2007-02-22 17:40:31
|
There is the following comment in include/pub_tool_errormgr.h above VG_(maybe_record_error): The `extra' field can be stack-allocated; it will be copied by the core if needed (but it won't be copied if it's NULL). I do not understand this comment -- how can Valgrind's core copy the contents of the data the 'extra' pointer points at if it doesn't know the size of this data structure ? In the drd tool I allocate these 'extra' fields on the stack, but I'm afraid that this is the cause of the crash when starting the drd tool with Valgrind's command-line option -v. -- Regards, Bart Van Assche. |
|
From: Nicholas N. <nj...@cs...> - 2007-02-22 22:08:23
|
On Thu, 22 Feb 2007, Bart Van Assche wrote:
> There is the following comment in include/pub_tool_errormgr.h above
> VG_(maybe_record_error):
>
> The `extra' field can be stack-allocated; it will be copied by the
> core if needed (but it
> won't be copied if it's NULL).
>
> I do not understand this comment -- how can Valgrind's core copy the
> contents of the data the 'extra' pointer points at if it doesn't know
> the size of this data structure ? In the drd tool I allocate these
> 'extra' fields on the stack, but I'm afraid that this is the cause of
> the crash when starting the drd tool with Valgrind's command-line
> option -v.
The last sentence of the comment for the tool-defined 'update_extra'
function explains:
// Should fill in any details that could be postponed until after the
// decision whether to ignore the error (ie. details not affecting the
// result of VG_(tdict).tool_eq_Error()). This saves time when errors
// are ignored.
// Yuk.
// Return value: must be the size of the `extra' part in bytes -- used by
// the core to make a copy.
UInt (*update_extra)(Error* err),
The whole mechanism is ugly but I've never been able to think of a way to
improve it much.
Nick
|
|
From: Bart V. A. <bar...@gm...> - 2007-02-23 14:35:30
|
On 2/22/07, Nicholas Nethercote <nj...@cs...> wrote: > The last sentence of the comment for the tool-defined 'update_extra' > function explains: > > // Should fill in any details that could be postponed until after the > // decision whether to ignore the error (ie. details not affecting the > // result of VG_(tdict).tool_eq_Error()). This saves time when errors > // are ignored. > // Yuk. > // Return value: must be the size of the `extra' part in bytes -- used by > // the core to make a copy. > UInt (*update_extra)(Error* err), > > The whole mechanism is ugly but I've never been able to think of a way to > improve it much. Thanks for the info -- this allowed me to fix the crash in drd triggered by -v. Regarding passing the size of the 'extra' part to Valgrind's core: is this size already known at the time VG_(maybe_record_error)() is called in every tool ? In that case it would be more elegant to have e.g. a function VG_(maybe_record_error2)() that accepts one more argument than VG_(maybe_record_error)(), namely the size of the object 'extra' points to. Bart. |