Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Ulrich Weigand <Ulrich.Weigand@de.ibm.com>
To: "akamath996@gmail.com" <akamath996@gmail.com>,
	"tom@tromey.com" <tom@tromey.com>,
	"simon.marchi@polymtl.ca" <simon.marchi@polymtl.ca>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>,
	SANGAMESH MALLAYYA <sangamesh.swamy@in.ibm.com>,
	PRAJWAL B MEHENDARKAR <PRAJWAL.B.MEHENDARKAR@ibm.com>,
	Aditya Kamath <Aditya.Kamath1@ibm.com>
Subject: Re: [PATCH] Fix crash in AIX when current working directory is NULL
Date: Fri, 26 Jun 2026 16:15:33 +0000	[thread overview]
Message-ID: <dc2c3b6adfd21e387b061944f76dabde1fd2982e.camel@de.ibm.com> (raw)
In-Reply-To: <20260622091114.18783-2-akamath996@gmail.com>

Aditya Vidyadhar Kamath wrote:  

>diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c  
>index 84b1480dbcb..7962acc784d 100644  
>--- a/gdb/dwarf2/read.c  
>+++ b/gdb/dwarf2/read.c  
>@@ -859,7 +859,7 @@ dwarf2_per_bfd::dwarf2_per_bfd (bfd *obfd, const
>dwarf2_debug_sections *names,  
>  bool can_copy_) 
>   : obfd (obfd),  
>     can_copy (can_copy_),  
>-    captured_cwd (current_directory),  
>+    captured_cwd (current_directory == NULL ? "" :
current_directory),  
>     captured_debug_dir (debug_file_directory)  

The captured_cwd logic was introduced by Tom Tromey in
commit 3fbf1a34f10aa6a67d9f96c437e8f9dc57832d22.  Previously,
in the case where current_directory == NULL, that NULL pointer
was passed directly to openp, which passes it on to gdb_abspath.

That latter routine does in fact has extra code handling a NULL
cwd input (basically treating any input path as absolute).
This is different from how an empty string as cwd input is
handled (for an empty string, it looks like an extra '/'
is prepended).

So even with this proposed patch, we'd still have a change in
behavior (though no longer a crash) as compared to the version
before Tom's commit above.

Tom, any thoughts on how this should be handled?  Should we
add another check when passing captured_cwd to openp?
Change captured_cwd to something like std::optional<std::string>?

Bye,
Ulrich

      parent reply	other threads:[~2026-06-26 16:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-22  9:11 Aditya Vidyadhar Kamath
2026-06-23 17:10 ` Keith Seitz
2026-06-24 11:50   ` Aditya Kamath
2026-06-26 14:56     ` Tom Tromey
2026-06-29 12:35       ` Aditya Kamath
2026-06-26 16:15 ` Ulrich Weigand [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dc2c3b6adfd21e387b061944f76dabde1fd2982e.camel@de.ibm.com \
    --to=ulrich.weigand@de.ibm.com \
    --cc=Aditya.Kamath1@ibm.com \
    --cc=PRAJWAL.B.MEHENDARKAR@ibm.com \
    --cc=akamath996@gmail.com \
    --cc=gdb-patches@sourceware.org \
    --cc=sangamesh.swamy@in.ibm.com \
    --cc=simon.marchi@polymtl.ca \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox