Skip to content

Creation of CFGEmulated for Redis fails #6229

@sebastiaoamaro

Description

@sebastiaoamaro

Description

Hi,
I am trying to build a CFG (emulated, auto_load_libs=False) of Redis version 8.0.3.
I was running with auto_load_libs=False, which was unintentional, with True, it works.
But I will still leave the bug here.
The error is:

  File "/toexfi/binary_analysis/cfg_analyzer.py", line 904, in main                                                               12:23:18 [40/237]
    project.analyses.CFGEmulated()
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/analyses/analysis.py", line 266, in __call__
    r = w(*args, **kwargs)
        ^^^^^^^^^^^^^^^^^^
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/analyses/analysis.py", line 251, in wrapper
    oself.__init__(*args, **kwargs)
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/analyses/cfg/cfg_emulated.py", line 357, in __init__
    self._analyze()
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/analyses/forward_analysis/forward_analysis.py", line 277, in _analyze
    self._analysis_core_baremetal()
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/analyses/forward_analysis/forward_analysis.py", line 409, in _analysis_core_baremeta
l
    self._pre_job_handling(job_info.job)
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/analyses/cfg/cfg_emulated.py", line 1217, in _pre_job_handling
    self._model.add_node(block_id, cfg_node)
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/knowledge_plugins/cfg/cfg_model.py", line 317, in add_node
    self.graph.add_node(node)
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/knowledge_plugins/cfg/spilling_cfg.py", line 781, in add_node
    self._graph.add_node(block_key, **attr)
  File "/home/vagrant/.local/lib/python3.12/site-packages/networkx/classes/digraph.py", line 492, in add_node
    self._succ[node_for_adding] = self.adjlist_inner_dict_factory()
    ~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/knowledge_plugins/cfg/spilling_digraph.py", line 117, in __setitem__
    self._on_entry_stored(key)
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/knowledge_plugins/cfg/spilling_digraph.py", line 160, in _on_entry_stored
    self._evict_lru()
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/knowledge_plugins/cfg/spilling_digraph.py", line 168, in _evict_lru
    if self._evict_n(batch_size) == 0:
       ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/knowledge_plugins/cfg/spilling_digraph.py", line 198, in _evict_n
    self._save_to_lmdb(entries_to_save)
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/knowledge_plugins/cfg/spilling_digraph.py", line 370, in _save_to_lmdb
    value = self._serialize_inner_dict(inner_dict)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vagrant/.local/lib/python3.12/site-packages/angr/knowledge_plugins/cfg/spilling_digraph.py", line 260, in _serialize_inner_dict
    key_bytes = struct.pack("<Q", dst_key[0]) + struct.pack("<H", dst_key[1])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
struct.error: required argument is not an integer

Steps to reproduce the bug

The code to reproduce the bug is:

import sys
import angr

def main():
    binary = sys.argv[1]
    project = angr.Project(binary, auto_load_libs=False)
    cfg = project.analyses.CFGEmulated()

if __name__ == "__main__":
    main()

Where the first arg is the binary of redis-server 8.0.3

Environment

Running on Ubuntu 24.04, Python 3.12.3, and angr 9.2.204.

Additional context

No response

Metadata

Metadata

Assignees

Labels

bugSomething is broken

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