You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Attributes can be used after deallocation (see e.g. osandov/drgn#280). That's because an explicit or implicit (like in the above case) reference may still exist after the attribute is cleared.
The text was updated successfully, but these errors were encountered:
Modify kdump_attr_ref_get() to return data that is guaranteed to stay
valid. In particular:
- string attributes are duplicated
- blob and bitmap attributes increment their reference count
Of course, the caller should free these resources again when the data is no
longer needed. Add a kdump_attr_discard() function for that purpose.
Rationale
When used on a string, blob or bitmap attribute, kdump_get_attr(),
kdump_get_typed_attr() and derivatives will return a pointer to the
underlying data without any lifetime guarantees. Such pointers may become
dangling whenever the caller touches the containing dump file object. In
the extreme case, another thread may invalidate the pointer before it is
even returned to the caller.
However, most users are happy with these limitations, so keep the simple
API unchanged, only updating documentation.
There is also an attribute API based on references (kdump_attr_ref_t).
This API was primarily intended to allow iterating over attributes in a
thread-safe manner (although this is not yet fully implemented, cf. #71),
but it can be also used to get attribute values, see kdump_attr_ref_get().
Since this API is designed as thread-safe, it makes little sense to have a
thread-unsafe function to get attribute value.
It sounds fair that users of this API are now required to adapt their code
to avoid memory leaks.
Fixes: #82
Signed-off-by: Petr Tesarik <[email protected]>
Attributes can be used after deallocation (see e.g. osandov/drgn#280). That's because an explicit or implicit (like in the above case) reference may still exist after the attribute is cleared.
The text was updated successfully, but these errors were encountered: