Hi Aaron,

On Sun, Jan 19, 2025 at 10:20:34PM -0500, Aaron Merey wrote:
>       * libdw/dwarf_offdie.c (__libdw_offdie): Use dwarf_lock.

What exactly is "protected" here?  If it is just the __libdw_findcu
call, then it seems the lock is too wide/early. It could just be taken
just before that call, the code before it doesn't seem to need to be
under this lock.

> Signed-off-by: Aaron Merey <ame...@redhat.com>
> 
> ---
>  libdw/dwarf_offdie.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/libdw/dwarf_offdie.c b/libdw/dwarf_offdie.c
> index 883720de..74eac420 100644
> --- a/libdw/dwarf_offdie.c
> +++ b/libdw/dwarf_offdie.c
> @@ -43,11 +43,13 @@ __libdw_offdie (Dwarf *dbg, Dwarf_Off offset, Dwarf_Die 
> *result,
>    if (dbg == NULL)
>      return NULL;
>  
> +  mutex_lock (dbg->dwarf_lock);
>    Elf_Data *const data = dbg->sectiondata[debug_types ? IDX_debug_types
>                                         : IDX_debug_info];
>    if (data == NULL || offset >= data->d_size)
>      {
>        __libdw_seterrno (DWARF_E_INVALID_DWARF);
> +      mutex_unlock (dbg->dwarf_lock);
>        return NULL;
>      }
>  
> @@ -66,6 +68,7 @@ __libdw_offdie (Dwarf *dbg, Dwarf_Off offset, Dwarf_Die 
> *result,
>        result = NULL;
>      }
>  
> +  mutex_unlock (dbg->dwarf_lock);
>    return result;
>  }
>  
> -- 
> 2.47.1
> 

Reply via email to