From patchwork Fri May 4 18:30:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 27115 Received: (qmail 59897 invoked by alias); 4 May 2018 18:30:40 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 59320 invoked by uid 89); 4 May 2018 18:30:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 04 May 2018 18:30:20 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4547F117C81 for ; Fri, 4 May 2018 14:30:05 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id baEEHNoxaq4q for ; Fri, 4 May 2018 14:30:05 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id 35D1B117C7B for ; Fri, 4 May 2018 14:30:05 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4233) id 335B8487; Fri, 4 May 2018 14:30:05 -0400 (EDT) From: Joel Brobecker To: gdb-patches@sourceware.org Subject: [PATCH 1/3] [gdbserver/win32] fatal "glob could not process pattern '(null)'" error Date: Fri, 4 May 2018 14:30:01 -0400 Message-Id: <1525458603-33351-2-git-send-email-brobecker@adacore.com> In-Reply-To: <1525458603-33351-1-git-send-email-brobecker@adacore.com> References: <1525458603-33351-1-git-send-email-brobecker@adacore.com> Trying to start GDBserver on Windows currently yields the following error... $ gdbserver.exe --once :4444 simple_main.exe glob could not process pattern '(null)'. Exiting ... after which GDB terminates with a nonzero status. This is because create_process in win32-low.c calls gdb_tilde_expand with the result of a call to get_inferior_cwd without verifying that the returned directory is not NULL: | static BOOL | create_process (const char *program, char *args, | DWORD flags, PROCESS_INFORMATION *pi) | { | const char *inferior_cwd = get_inferior_cwd (); | std::string expanded_infcwd = gdb_tilde_expand (inferior_cwd); This patch avoids this by only calling gdb_tilde_expand when INFERIOR_CWD is not NULL, which is similar to what is done on GNU/Linux for instance. gdb/gdbserver/ChangeLog: * win32-low.c (create_process): Only call gdb_tilde_expand if inferior_cwd is not NULL. --- gdb/gdbserver/win32-low.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gdb/gdbserver/win32-low.c b/gdb/gdbserver/win32-low.c index 9f0c4e4..db5dd49 100644 --- a/gdb/gdbserver/win32-low.c +++ b/gdb/gdbserver/win32-low.c @@ -556,7 +556,6 @@ create_process (const char *program, char *args, DWORD flags, PROCESS_INFORMATION *pi) { const char *inferior_cwd = get_inferior_cwd (); - std::string expanded_infcwd = gdb_tilde_expand (inferior_cwd); BOOL ret; #ifdef _WIN32_WCE @@ -576,6 +575,7 @@ create_process (const char *program, char *args, if (inferior_cwd != NULL) { + std::string expanded_infcwd = gdb_tilde_expand (inferior_cwd); std::replace (expanded_infcwd.begin (), expanded_infcwd.end (), '/', '\\'); wcwd = alloca ((expanded_infcwd.size () + 1) * sizeof (wchar_t)); @@ -607,7 +607,10 @@ Could not convert the expanded inferior cwd to wide-char.")); TRUE, /* inherit handles */ flags, /* start flags */ NULL, /* environment */ - expanded_infcwd.c_str (), /* current directory */ + /* current directory */ + (inferior_cwd == NULL + ? NULL + : gdb_tilde_expand (inferior_cwd).c_str()), &si, /* start info */ pi); /* proc info */ #endif