[v2] Fix Windows regression

Message ID 20240820135629.3551547-1-tromey@adacore.com
State New
Headers
Series [v2] Fix Windows regression |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 warning Patch is already merged
linaro-tcwg-bot/tcwg_gdb_build--master-arm warning Patch is already merged

Commit Message

Tom Tromey Aug. 20, 2024, 1:56 p.m. UTC
  commit cb9f919f ("gdb: add program_space parameter to
lookup_minimal_symbol_text") caused a crash on Windows.  In this
function, section can be nullptr, but it is unconditionally
dereferenced by the change introduced by the patch.

I tested this using the AdaCore internal test suite.

v2: always use current_program_space, reverting to be behavior before
cb9f919f.
---
 gdb/symtab.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Simon Marchi Aug. 20, 2024, 2:04 p.m. UTC | #1
On 8/20/24 9:56 AM, Tom Tromey wrote:
> commit cb9f919f ("gdb: add program_space parameter to
> lookup_minimal_symbol_text") caused a crash on Windows.  In this
> function, section can be nullptr, but it is unconditionally
> dereferenced by the change introduced by the patch.
> 
> I tested this using the AdaCore internal test suite.
> 
> v2: always use current_program_space, reverting to be behavior before
> cb9f919f.
> ---
>  gdb/symtab.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/gdb/symtab.c b/gdb/symtab.c
> index 9b3562eeb30..ce5e2520bd1 100644
> --- a/gdb/symtab.c
> +++ b/gdb/symtab.c
> @@ -3174,7 +3174,7 @@ find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
>      if (msymbol.minsym->type () == mst_solib_trampoline)
>        {
>  	bound_minimal_symbol mfunsym
> -	  = lookup_minimal_symbol_text (section->objfile->pspace (),
> +	  = lookup_minimal_symbol_text (current_program_space,
>  					msymbol.minsym->linkage_name (),
>  					nullptr);
>  
> -- 
> 2.45.0
> 

LGTM, thanks.

Approved-By: Simon Marchi <simon.marchi@efficios.com>

Simon
  

Patch

diff --git a/gdb/symtab.c b/gdb/symtab.c
index 9b3562eeb30..ce5e2520bd1 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -3174,7 +3174,7 @@  find_pc_sect_line (CORE_ADDR pc, struct obj_section *section, int notcurrent)
     if (msymbol.minsym->type () == mst_solib_trampoline)
       {
 	bound_minimal_symbol mfunsym
-	  = lookup_minimal_symbol_text (section->objfile->pspace (),
+	  = lookup_minimal_symbol_text (current_program_space,
 					msymbol.minsym->linkage_name (),
 					nullptr);