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 <ame...@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
> 

Reply via email to