[windows] Fix out-of-memory failure in some of the tests
ClosedPublic

Authored by stella.stamenova on Tue, Jul 10, 3:26 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Any idea Why does the call fail?

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.

Thanks,
-Stella

From: Zachary Turner <zturner@google.com>
Sent: Tuesday, July 10, 2018 3:38 PM
To: reviews+D49159+public+f5176ed1b1117dd2@reviews.llvm.org
Cc: Stella Stamenova <stilis@microsoft.com>; aaron.lee.smith <aaron.lee.smith@gmail.com>; llvm-commits@lists.llvm.org
Subject: Re: [PATCH] D49159: [windows] Fix out-of-memory failure in some of the tests

Any idea Why does the call fail?

zturner accepted this revision.Wed, Jul 11, 11:38 AM
This revision is now accepted and ready to land.Wed, Jul 11, 11:38 AM
This revision was automatically updated to reflect the committed changes.

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?