[PATCH 09/15] dwarf_onesrcline.c: Add locking
Mark Wielaard
mark@klomp.org
Thu Jan 23 00:15:27 GMT 2025
Hi Aaron,
On Sun, Jan 19, 2025 at 10:20:35PM -0500, Aaron Merey wrote:
> * libdw/dwarf_onesrcline.c (dwarf_onesrcline): Use dwarf_lock.
Is this really necessary? When the user calls dwarf_onesrcline
wouldn't they already have a fully setup Dwarf_Lines? Can it still
change concurrently?
> Signed-off-by: Aaron Merey <amerey@redhat.com>
>
> ---
> libdw/dwarf_onesrcline.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/libdw/dwarf_onesrcline.c b/libdw/dwarf_onesrcline.c
> index 5d3c3ded..1a16269a 100644
> --- a/libdw/dwarf_onesrcline.c
> +++ b/libdw/dwarf_onesrcline.c
> @@ -40,11 +40,16 @@ dwarf_onesrcline (Dwarf_Lines *lines, size_t idx)
> if (lines == NULL)
> return NULL;
>
> + mutex_lock (lines->dbg->dwarf_lock);
> +
> if (idx >= lines->nlines)
> {
> __libdw_seterrno (DWARF_E_INVALID_LINE_IDX);
> return NULL;
> }
>
> - return &lines->info[idx];
> + Dwarf_Line *result = &lines->info[idx];
> + mutex_unlock (lines->dbg->dwarf_lock);
> +
> + return result;
> }
> --
> 2.47.1
>
More information about the Elfutils-devel
mailing list