[PATCH] Return TARGET_XFER_EOF if reading at the end of TARGET_OBJECT_SIGNAL_INFO.

John Baldwin jhb@FreeBSD.org
Fri May 10 19:39:00 GMT 2019


On 5/10/19 10:40 AM, Tom Tromey wrote:
>>>>>> "John" == John Baldwin <jhb@FreeBSD.org> writes:
> 
> John> This fixes an assertion failure if a request is made to read just past
> John> the end of a native thread's signal information structure.
> 
> I am curious to know where the assertion happens.
> 
> linux-nat.c doesn't seem to return TARGET_XFER_EOF here (see
> linux_xfer_siginfo), so I wonder if either linux-nat.c needs a fix, or
> if the bug is somewhere else.

I had to try hard to provoke it.  I had a bug in out-of-tree patches to
fbsd-nat.c that resulted in getting the siginfo_size wrong (too small)
compared to the generated type for $_siginfo for the target architecture.
The size mismatch just so happened to result in a field that started on
the byte location of the end of the too-small size and so 'p $_siginfo'
tried to read a field at that exact offset and tripped the assertion at
the bottom of target_xfer_partial:

  /* Check implementations of to_xfer_partial update *XFERED_LEN
     properly.  Do assertion after printing debug messages, so that we
     can find more clues on assertion failure from debugging messages.  */
  if (retval == TARGET_XFER_OK || retval == TARGET_XFER_UNAVAILABLE)
    gdb_assert (*xfered_len > 0);
 

-- 
John Baldwin



More information about the Gdb-patches mailing list