Describe the bug
Mapping a memory region starting at address 0 and then calling ql.mem.unmap_all does not unmap the region.
Sample Code
import qiling
from qiling.const import QL_ARCH
ql = qiling.Qiling(code=b"\0", archtype=QL_ARCH.ARM, ostype='linux')
ql.mem.map(addr=0, size=0x1000)
ql.mem.unmap_all()
assert ql.mem.map_info == [], ql.mem.map_info
Actual behavior
$ python main.py
Traceback (most recent call last):
File "main.py", line 7, in <module>
assert ql.mem.map_info == [], ql.mem.map_info
AssertionError: [(0, 4096, 7, '[mapped]', False)]
Expected behavior
No assertion error and the entire memory space is reclaimed (as the docstring says).
Additional context
This region is not unmapped because begin is 0, which causes the begin and end guard in the below code to be False. I am not sure why this check is even there - I think the if should be removed, and self.unmap should always be executed.
|
def unmap_all(self): |
|
"""Reclaim the entire memory space. |
|
""" |
|
|
|
for begin, end, _ in self.ql.uc.mem_regions(): |
|
if begin and end: |
|
self.unmap(begin, end - begin + 1) |
Describe the bug
Mapping a memory region starting at address 0 and then calling
ql.mem.unmap_alldoes not unmap the region.Sample Code
Actual behavior
Expected behavior
No assertion error and the entire memory space is reclaimed (as the docstring says).
Additional context
This region is not unmapped because
beginis 0, which causes thebegin and endguard in the below code to beFalse. I am not sure why this check is even there - I think theifshould be removed, andself.unmapshould always be executed.qiling/qiling/os/memory.py
Lines 417 to 423 in 59d31c2