When ReadProcessMemory fails, bytes_read is sometimes set to a large garbage value. In that case, we need to set it back to zero before returning or the garbage value will be used to allocate memory later causing LLDB to crash with an out of memory error.
The memory address that we are reading from is invalid in the test that is failing – it has not been initialized, so it points to an invalid location. ReadProcessMemory can fail for a number of reasons and in this case I believe it’s because it doesn’t have access to read from that particular memory location.
From: Zachary Turner <firstname.lastname@example.org>
Sent: Tuesday, July 10, 2018 3:38 PM
Cc: Stella Stamenova <email@example.com>; aaron.lee.smith <firstname.lastname@example.org>; email@example.com
Subject: Re: [PATCH] D49159: [windows] Fix out-of-memory failure in some of the tests
Any idea Why does the call fail?
The comment for ReadMemory (in Process.h) says it returns 0 on error, but DoReadMemory doesn't say that. Also the comments are out of date and don't mention the error parameter. Could you fix that so newer plugin authors will know to do the right thing too?