[01/15] Add eu_search_tree_init

Message ID 20250120032041.280173-1-amerey@redhat.com
State Committed
Delegated to: Mark Wielaard
Headers
Series [01/15] Add eu_search_tree_init |

Commit Message

Aaron Merey Jan. 20, 2025, 3:20 a.m. UTC
  * libdw/dwarf_begin_elf.c (dwarf_begin_elf): Initialize
	eu_search_trees.

Signed-off-by: Aaron Merey <amerey@redhat.com>

---
 libdw/dwarf_begin_elf.c | 6 ++++++
 1 file changed, 6 insertions(+)
  

Comments

Mark Wielaard Jan. 22, 2025, 3:22 p.m. UTC | #1
Hi Aaron,

On Sun, 2025-01-19 at 22:20 -0500, Aaron Merey wrote:
> 	* libdw/dwarf_begin_elf.c (dwarf_begin_elf): Initialize
> 	eu_search_trees.

I see the same are already eu_search_tree_fini in dwarf_end. So my only
question is how this worked before?

Whatever the answer is though, this looks good.

Thanks,

Mark

> Signed-off-by: Aaron Merey <amerey@redhat.com>
> 
> ---
>  libdw/dwarf_begin_elf.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
> index e4826dda..c8292913 100644
> --- a/libdw/dwarf_begin_elf.c
> +++ b/libdw/dwarf_begin_elf.c
> @@ -580,6 +580,12 @@ dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp)
>        return NULL;
>      }
>    rwlock_init (result->dwarf_lock);
> +  eu_search_tree_init (&result->cu_tree);
> +  eu_search_tree_init (&result->tu_tree);
> +  eu_search_tree_init (&result->split_tree);
> +  eu_search_tree_init (&result->macro_ops_tree);
> +  eu_search_tree_init (&result->files_lines_tree);
> +
>    result->mem_stacks = 0;
>    result->mem_tails = NULL;
>
  
Aaron Merey Jan. 24, 2025, 2:12 a.m. UTC | #2
Hi Mark,

On Wed, Jan 22, 2025 at 10:23 AM Mark Wielaard <mark@klomp.org> wrote:
> On Sun, 2025-01-19 at 22:20 -0500, Aaron Merey wrote:
> >       * libdw/dwarf_begin_elf.c (dwarf_begin_elf): Initialize
> >       eu_search_trees.
>
> I see the same are already eu_search_tree_fini in dwarf_end. So my only
> question is how this worked before?

I commented out these inits and re-ran the testsuite with thread safety
and valgrind enabled (I did a run with memcheck and a run with
helgrind).  All tests passed, including the thread safety ones.

I'm not sure what's going on but I have seen at least one test failure
due to these missing inits.  Possibly rwlock and tsearch/tfind
have a chance to work on certain uninitialized values, e.g. if they
happen to be 0?

Aaron
  

Patch

diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index e4826dda..c8292913 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -580,6 +580,12 @@  dwarf_begin_elf (Elf *elf, Dwarf_Cmd cmd, Elf_Scn *scngrp)
       return NULL;
     }
   rwlock_init (result->dwarf_lock);
+  eu_search_tree_init (&result->cu_tree);
+  eu_search_tree_init (&result->tu_tree);
+  eu_search_tree_init (&result->split_tree);
+  eu_search_tree_init (&result->macro_ops_tree);
+  eu_search_tree_init (&result->files_lines_tree);
+
   result->mem_stacks = 0;
   result->mem_tails = NULL;