This is the mail archive of the
gdb-prs@sourceware.org
mailing list for the GDB project.
[Bug gdb/22388] New: assertion "xfered_len>0" in target.c for remote connection
- From: "pcarroll at codesourcery dot com" <sourceware-bugzilla at sourceware dot org>
- To: gdb-prs at sourceware dot org
- Date: Thu, 02 Nov 2017 20:42:02 +0000
- Subject: [Bug gdb/22388] New: assertion "xfered_len>0" in target.c for remote connection
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=22388
Bug ID: 22388
Summary: assertion "xfered_len>0" in target.c for remote
connection
Product: gdb
Version: HEAD
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: pcarroll at codesourcery dot com
Target Milestone: ---
We have a customer who is using a Corelis gdb server to connect to gdb.
Occasionally, the gdb server will send a 0-byte block of memory for a read.
When this happens, gdb gives an assertion from target.c:
internal-error: target_xfer_partial: Assertion `*xfered_len > 0' failed.
This problem is almost identical to that fixed in
https://sourceware.org/ml/gdb-patches/2014-02/msg00636.html
In this case, remote.c needs to be modified to return TARGET_XFER_EOF instead
of TARGET_XFER_OK or TARGET_XFER_UNAVAILABLE when 0 bytes are to be
transferred.
The proposed fix would be:
--- fsf/remote.c 2017-11-02 15:21:31.358857300 -0500
+++ fix/remote.c 2017-11-02 15:24:35.536391700 -0500
@@ -8264,7 +8264,7 @@ remote_write_bytes_aux (const char *head
/* Return UNITS_WRITTEN, not TODO_UNITS, in case escape chars caused us to
send fewer units than we'd planned. */
*xfered_len_units = (ULONGEST) units_written;
- return TARGET_XFER_OK;
+ return (*xfered_len_units != 0) ? TARGET_XFER_OK : TARGET_XFER_EOF;
}
/* Write memory data directly to the remote machine.
@@ -8358,7 +8358,7 @@ remote_read_bytes_1 (CORE_ADDR memaddr,
decoded_bytes = hex2bin (p, myaddr, todo_units * unit_size);
/* Return what we have. Let higher layers handle partial reads. */
*xfered_len_units = (ULONGEST) (decoded_bytes / unit_size);
- return TARGET_XFER_OK;
+ return (*xfered_len_units != 0) ? TARGET_XFER_OK : TARGET_XFER_EOF;
}
/* Using the set of read-only target sections of remote, read live
@@ -8455,13 +8455,14 @@ remote_read_bytes (struct target_ops *op
res = remote_xfer_live_readonly_partial (ops, myaddr, memaddr,
len, unit_size,
xfered_len);
if (res == TARGET_XFER_OK)
- return TARGET_XFER_OK;
+ return (*xfered_len != 0) ? TARGET_XFER_OK : TARGET_XFER_EOF;
else
{
/* No use trying further, we know some memory starting
at MEMADDR isn't available. */
*xfered_len = len;
- return TARGET_XFER_UNAVAILABLE;
+ return (*xfered_len != 0) ?
+ TARGET_XFER_UNAVAILABLE : TARGET_XFER_EOF;
}
}
@@ -10386,7 +10387,7 @@ remote_write_qxfer (struct target_ops *o
unpack_varlen_hex (rs->buf, &n);
*xfered_len = n;
- return TARGET_XFER_OK;
+ return (*xfered_len != 0) ? TARGET_XFER_OK : TARGET_XFER_EOF;
}
/* Read OBJECT_NAME/ANNEX from the remote target using a qXfer packet.
@@ -10687,7 +10688,7 @@ remote_xfer_partial (struct target_ops *
strcpy ((char *) readbuf, rs->buf);
*xfered_len = strlen ((char *) readbuf);
- return TARGET_XFER_OK;
+ return (*xfered_len != 0) ? TARGET_XFER_OK : TARGET_XFER_EOF;
}
/* Implementation of to_get_memory_xfer_limit. */
--
You are receiving this mail because:
You are on the CC list for the bug.