public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: "Willgerodt, Felix" <felix.willgerodt@intel.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 1/1] gdbserver, linux-low: add a couple of nullptr assertions.
Date: Tue, 29 Aug 2023 13:48:22 +0000	[thread overview]
Message-ID: <20230829134822.157625-1-felix.willgerodt@intel.com> (raw)

This safeguards a couple of places that may theoretically return NULL but
must not in this specific context.  These were found by a static analysis tool.
---
 gdbserver/linux-low.cc | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc
index e1806ade82f..40b6a907ad9 100644
--- a/gdbserver/linux-low.cc
+++ b/gdbserver/linux-low.cc
@@ -1169,6 +1169,7 @@ linux_process_target::attach (unsigned long pid)
   /* Don't ignore the initial SIGSTOP if we just attached to this
      process.  It will be collected by wait shortly.  */
   initial_thread = find_thread_ptid (ptid_t (pid, pid));
+  gdb_assert (initial_thread != nullptr);
   initial_thread->last_resume_kind = resume_stop;
 
   /* We must attach to every LWP.  If /proc is mounted, use that to
@@ -1198,6 +1199,7 @@ linux_process_target::attach (unsigned long pid)
       gdb_assert (lwpid > 0);
 
       lwp = find_lwp_pid (ptid_t (lwpid));
+      gdb_assert (lwp != nullptr);
 
       if (!WIFSTOPPED (wstat) || WSTOPSIG (wstat) != SIGSTOP)
 	{
@@ -1572,6 +1574,7 @@ linux_process_target::detach (process_info *process)
     });
 
   main_lwp = find_lwp_pid (ptid_t (process->pid));
+  gdb_assert (main_lwp != nullptr);
   detach_one_lwp (main_lwp);
 
   mourn (process);
@@ -2512,6 +2515,7 @@ linux_process_target::wait_for_event_filtered (ptid_t wait_ptid,
   else if (filter_ptid != null_ptid)
     {
       requested_child = find_lwp_pid (filter_ptid);
+      gdb_assert (requested_child != nullptr);
 
       if (stopping_threads == NOT_STOPPING_THREADS
 	  && requested_child->status_pending_p
-- 
2.34.1

Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de <http://www.intel.de>
Managing Directors: Christin Eisenschmid, Sharon Heck, Tiffany Doon Silva  
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928


             reply	other threads:[~2023-08-29 13:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29 13:48 Willgerodt, Felix [this message]
2023-08-29 15:41 ` Tom Tromey
2023-08-30  6:40   ` Willgerodt, Felix

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=20230829134822.157625-1-felix.willgerodt@intel.com \
    --to=felix.willgerodt@intel.com \
    --cc=gdb-patches@sourceware.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).