Open
Description
In SBMemoryRegionInfoListExtensions, the __iter__
function always yields the same SBMemoryRegionInfo
reference, but each loop the content of the info will be updated.
Using the example that I wrote in the docs:
readable_regions = []
for region in exe_ctx.GetProcess().GetMemoryRegions():
if region.IsReadable():
readable_regions.append(region)
We end up with a list all to the same region
This is because in the iter:
def __iter__(self):
'''Iterate over all the memory regions in a lldb.SBMemoryRegionInfoList object.'''
import lldb
size = self.GetSize()
region = lldb.SBMemoryRegionInfo()
for i in range(size):
self.GetMemoryRegionAtIndex(i, region)
yield region
Region is a reference and if you assign it to anything, that new variable will be mutated in the next loop.
I filed this as an issue to communicate the bug because I assume a user has encountered this without realizing (because it's not very apparent).