opengl: Fix QemuPipeStream::readFully reading beyond end of buffer

When GPU emulation is enabled, the emulator sometimes freezes, with an
error message in logcat similar to the following:

 QemuPipeStream::readFully failed (buf 0x7f9cd8ab8000): Bad address

Some users have reported the same issue, e.g.:

The root cause is that QemuPipeStream::readFully(void *buf, size_t len)
may attempt to read beyond (buf + len), resulting in a -EFAULT return
value from the goldfish/qemu pipe driver.

Fix this bug to improve the stability of the emulator. In addition,

 - Add more information to the said error message to facilitate future
 - Use "%zu" instead of "%d" for logging size_t variables.

Change-Id: I8785fee0427fd6c0f25237470b346e769a82c992
Signed-off-by: Yu Ning <>
Signed-off-by: Pengcheng Chen <>
1 file changed