Issue |
144439
|
Summary |
[LLDB] SBMemoryRegionInfoListExtensions re-uses reference and then mutates it.
|
Labels |
new issue
|
Assignees |
|
Reporter |
Jlalond
|
In [SBMemoryRegionInfoListExtensions](https://github.com/llvm/llvm-project/blob/main/lldb/bindings/interface/SBMemoryRegionInfoListExtensions.i#L8), 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 we will in the contents every loop, but if you assign anything to this reference, it will then be mutated 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).
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs