<div dir="ltr">Hope it's ok to bump this again. No worries if you're busy, just want to make sure this doesn't get lost.</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jun 26, 2014 at 7:49 PM, Zachary Turner <span dir="ltr"><<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">+scallanan<div><br></div><div>I tried to add you to the review through Phab, but it looks like you weren't registered. Thanks</div>
</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jun 25, 2014 at 4:15 PM, Zachary Turner <span dir="ltr"><<a href="mailto:zturner@google.com" target="_blank">zturner@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The current strategy for host allocation is to choose a random address and attempt to allocate there, eventually failing if the allocation cannot be satisfied.<br>
<br>
The C standard only guarantees that RAND_MAX >= 32767, so for platforms where this is true allocations will fail with very high probability. On such platforms, you can reproduce this trivially by running lldb, typing "expr (3)" and then hitting enter you see a failure. Failures generally happen with a frequency of about 1 failure every 5 evaluations.<br>
<br>
I cannot come up with a good reason that the allocations need to look like "real" pointers, so this patch changes the allocation scheme to simply jump straight to the end and grab a free chunk of memory.<br>
<br>
<a href="http://reviews.llvm.org/D4300" target="_blank">http://reviews.llvm.org/D4300</a><br>
<br>
Files:<br>
source/Expression/IRMemoryMap.cpp<br>
<br>
Index: source/Expression/IRMemoryMap.cpp<br>
===================================================================<br>
--- source/Expression/IRMemoryMap.cpp<br>
+++ source/Expression/IRMemoryMap.cpp<br>
@@ -53,6 +53,8 @@<br>
lldb::ProcessSP process_sp = m_process_wp.lock();<br>
<br>
lldb::addr_t ret = LLDB_INVALID_ADDRESS;<br>
+ if (size == 0)<br>
+ return ret;<br>
<br>
if (process_sp && process_sp->CanJIT() && process_sp->IsAlive())<br>
{<br>
@@ -66,37 +68,13 @@<br>
return ret;<br>
}<br>
<br>
- for (int iterations = 0; iterations < 16; ++iterations)<br>
- {<br>
- lldb::addr_t candidate = LLDB_INVALID_ADDRESS;<br>
-<br>
- switch (target_sp->GetArchitecture().GetAddressByteSize())<br>
- {<br>
- case 4:<br>
- {<br>
- uint32_t random_data = rand();<br>
- candidate = random_data;<br>
- candidate &= ~0xfffull;<br>
- break;<br>
- }<br>
- case 8:<br>
- {<br>
- uint32_t random_low = rand();<br>
- uint32_t random_high = rand();<br>
- candidate = random_high;<br>
- candidate <<= 32ull;<br>
- candidate |= random_low;<br>
- candidate &= ~0xfffull;<br>
- break;<br>
- }<br>
- }<br>
-<br>
- if (IntersectsAllocation(candidate, size))<br>
- continue;<br>
-<br>
- ret = candidate;<br>
-<br>
- return ret;<br>
+ // Don't allocate from the zero page.<br>
+ ret = 0x1000;<br>
+ if (!m_allocations.empty()) {<br>
+ auto back = m_allocations.rbegin();<br>
+ lldb::addr_t addr = back->first;<br>
+ size_t size = back->second.m_size;<br>
+ ret = llvm::RoundUpToAlignment(addr+size, 4096);<br>
}<br>
<br>
return ret;<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>