public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "obilaniu at yahoo dot com" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug remote/14314] New: PID read as ULONGEST but written as int
Date: Fri, 29 Jun 2012 15:39:00 -0000	[thread overview]
Message-ID: <bug-14314-4717@http.sourceware.org/bugzilla/> (raw)

http://sourceware.org/bugzilla/show_bug.cgi?id=14314

             Bug #: 14314
           Summary: PID read as ULONGEST but written as int
           Product: gdb
           Version: unknown
            Status: NEW
          Severity: normal
          Priority: P2
         Component: remote
        AssignedTo: unassigned@sourceware.org
        ReportedBy: obilaniu@yahoo.com
    Classification: Unclassified


In remote.c, there is a mismatch in the way the remote protocol reads and
writes PTIDs in the functions write_ptid() and read_ptid().


- In read_ptid(), both the PID and the TID are declared and read as ULONGEST
(64-bit?).
- In write_ptid(), the PID is declared a (signed, 32-bit?) int and the TID is
declared a (signed, 64-bit?) long, but are written with xsnprintf() as unsigned
hex integers.


This asymmetry causes a problem on remote targets where there exists a PID (or
TID) larger than or equal to 2^31 (2^63). In that case, GDB will read correctly
the PID (TID) from the qxThreadInfo exchange, but when using the T packet to
later verify the existence of the PID (TID), instead of querying with the true
ID, it's two's complement is sent. This leads to gdbstub replying with E01 that
such a thread ID does not exist, and when subsequently GDB queries for what
threads do exist, it "rediscovers" the PID (TID) even though it was always
there.



Proposed solutions:
- Short-term: Repair write_ptid() by declaring both PID and TID to be ULONGEST
and replacing the xsnprintf() format specifier "%x" by "%lx".

- Long-term: Widen ptid_t 's PID field to a long-size integer. Also widen the
return type of ptid_get_pid(), ptid_build(), etc. accordingly.


The reason why high-valued PIDs and TIDs may exist is that on some systems, the
integer identifier is in fact a cast pointer to its (malloc-ed) block.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


             reply	other threads:[~2012-06-29 15:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-29 15:39 obilaniu at yahoo dot com [this message]
2012-06-29 15:42 ` [Bug remote/14314] " obilaniu at yahoo dot com
2022-01-07 21:03 ` tromey at sourceware dot org
2022-01-07 21:11 ` tromey at sourceware dot org

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=bug-14314-4717@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@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).