Skip to content

selftest does not work with loads from literal pool #381

Description

@mkannwischer
ldr x7, =0x07fffffe07fffffc

results in

INFO:instructions_a55.start.slothy.selftest:Running selftest (10 iterations)...
INFO:instructions_a55.start.slothy.selftest:Inferred that the following registers seem to act as pointers: set()
INFO:instructions_a55.start.slothy.selftest:Using default buffer size of 1024 bytes. If you want different buffer sizes, set selftest_address_registers manually.
ERROR:instructions_a55.start.slothy.selftest:Failed to emulate code using unicorn engine
ERROR:instructions_a55.start.slothy.selftest:Code
ERROR:instructions_a55.start.slothy.selftest:ldr x7, =0x07fffffe07fffffc
Traceback (most recent call last):
  File "/Users/matthiaskannwischer/git/slothy/slothy/helper.py", line 1545, in run_code
    mu.emu_start(CODE_BASE + offset, CODE_BASE + len(objcode))
  File "/Users/matthiaskannwischer/git/slothy/venv/lib/python3.11/site-packages/unicorn/unicorn_py3/unicorn.py", line 766, in emu_start
    raise UcError(status)
unicorn.unicorn_py3.unicorn.UcError: Unhandled CPU exception (UC_ERR_EXCEPTION)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/Users/matthiaskannwischer/git/slothy/test.py", line 128, in <module>
    main()
  File "/Users/matthiaskannwischer/git/slothy/test.py", line 114, in main
    run_test(
  File "/Users/matthiaskannwischer/git/slothy/test.py", line 110, in run_test
    t.run(**kwargs)
  File "/Users/matthiaskannwischer/git/slothy/common/OptimizationRunner.py", line 213, in run
    self.core(slothy, *self.extra_args)
  File "/Users/matthiaskannwischer/git/slothy/tests/naive/aarch64/_test.py", line 45, in core
    slothy.optimize(start="start", end="end")
  File "/Users/matthiaskannwischer/git/slothy/slothy/core/slothy.py", line 397, in optimize
    early, core, late, num_exceptional = Heuristics.periodic(body, logger, c)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/matthiaskannwischer/git/slothy/slothy/core/heuristics.py", line 373, in periodic
    res = Heuristics.linear(body, logger=logger, conf=conf)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/matthiaskannwischer/git/slothy/slothy/core/heuristics.py", line 460, in linear
    return Heuristics.optimize_binsearch(body, logger.getChild("slothy"), conf)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/matthiaskannwischer/git/slothy/slothy/core/heuristics.py", line 145, in optimize_binsearch
    return Heuristics.optimize_binsearch_internal(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/matthiaskannwischer/git/slothy/slothy/core/heuristics.py", line 290, in optimize_binsearch_internal
    success = core.optimize(source, **kwargs)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/matthiaskannwischer/git/slothy/slothy/core/core.py", line 1738, in optimize
    self._extract_result()
  File "/Users/matthiaskannwischer/git/slothy/slothy/core/core.py", line 2198, in _extract_result
    self._result.selftest(self.logger.getChild("selftest"))
  File "/Users/matthiaskannwischer/git/slothy/slothy/core/core.py", line 978, in selftest
    SelfTest.run(
  File "/Users/matthiaskannwischer/git/slothy/slothy/helper.py", line 1592, in run
    final_regs_old, final_mem_old = run_code(codeA, txt="old")
                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/matthiaskannwischer/git/slothy/slothy/helper.py", line 1552, in run_code
    raise SelfTestException(
slothy.helper.SelfTestException: Selftest failed: Unicorn failed to emulate code: Unhandled CPU exception (UC_ERR_EXCEPTION)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions