Conversation
The class does not define __contains__, so `addr in view` reaches ClemoryBase.__contains__, whose body is `raise NotImplementedError`. Answer it the way Clemory.__contains__ answers it once its own fast paths are exhausted: look the address up and report whether that raised. This reuses the last-backer cache __getitem__ maintains. No caller asks the question today. angr builds one of these for every CFGFast run through Loader.gen_ro_memview(), but nothing in angr or angr-management tests membership against the view, so this closes a hole in a public API rather than repairing a broken analysis.
|
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS Validation record for head
Caller survey behind the "no caller asks the question" claim in the description:
Caveats: the workspace-wide gate was not run — this machine's native libraries are pinned by running corpus sweeps and rebuilding them is forbidden, so validation is the cle suite, the two CI diff checks and the survey above. No corpus A/B: the change adds a method that nothing calls, so there is no behaviour for a sweep to move. |
|
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS Membership tests against the read-only view of Before — the same question the angr/cle master 0e77ade>>> entry = loader.main_object.entry; hex(entry)
'0x400580'
>>> entry in loader.memory
True
>>> entry in loader.memory_ro_view
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "cle/memory.py", line 33, in __contains__
raise NotImplementedError
NotImplementedError
>>> (entry - 0x10000) in loader.memory_ro_view
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "cle/memory.py", line 33, in __contains__
raise NotImplementedError
NotImplementedErrorAfter — the view answers, and agrees with the clemory it was flattened from: with this change>>> entry = loader.main_object.entry; hex(entry)
'0x400580'
>>> entry in loader.memory
True
>>> entry in loader.memory_ro_view
True
>>> (entry - 0x10000) in loader.memory_ro_view
False |
|
Corpus decompilation diffs can be found at angr/dec-snapshots@master...angr/cle_822 |
THIS MESSAGE WAS GENERATED BY AN AUTOMATED PROCESS
Problem
addr in viewraises on aClemoryReadOnlyView. Onbinaries/tests/x86_64/fauxware:Loader.gen_ro_memview()builds one of these for everyCFGFastrun and theclass is exported from
cle, so a question theClemorybehind it answerscannot be asked of the view. No caller asks it today: nothing in angr or
angr-management tests membership against the view. Nothing is broken; a public
read method cannot be called.
Root cause
ClemoryReadOnlyViewdoes not define__contains__, so it reachesClemoryBase.__contains__, whose body israise NotImplementedError.Fix
Answer it the way
Clemory.__contains__answers it once its own fast paths areexhausted: look the address up and report whether that raised. This reuses the
last-backer cache
__getitem__maintains and needs no bounds the class does notcarry.
findis inherited fromClemoryBasehere too and still raises. It is leftalone: it needs a decision about whether to search the flattened backers or
delegate to the clemory they were flattened from, which is a separate change.
Testing
test_clemory_read_only_view_containsloads fauxware, builds the read-only viewand asserts that the entry point is in it, that an address 0x10000 below it is
not, and that the view answers the same as the clemory it was flattened from at
every backer boundary, gaps included. It fails on master with
NotImplementedError.Validation: #822 (comment)
session: sharpen