Repository: angr/angr

Issue:
Angrdb Dump Failed
<!--
*Disclaimer:
The angr suite is maintained by a small team of volunteers.
While we cannot guarantee any timeliness for fixes and enhancements, we will do our best.
For more real-time help with angr, from us and the community, join our [Slack.](http://angr.io/invite/)*
-->
---

**Describe the bug.**

When I tried to save the ADB file, a bug is triggered.
The binary file is attached.

```
proj = angr.Project(binary_path, load_options={'auto_load_libs': False})
cfg = proj.analyses.CFG(show_progressbar=True)
db = AngrDB(proj)
db.dump(db_file)
```

```
  File "angr/angr/angrdb/db.py", line 36, in open_db
    yield Session
  File "angr/angr/angrdb/db.py", line 143, in dump
    KnowledgeBaseSerializer.dump(session, self.project.kb)
  File "angr/angr/angrdb/serializers/kb.py", line 36, in dump
    FunctionManagerSerializer.dump(session, db_kb, kb.functions)
  File "angr/angr/angrdb/serializers/funcs.py", line 29, in dump
    blob=func.serialize(),
  File "angr/angr/serializable.py", line 37, in serialize
    return self.serialize_to_cmessage().SerializeToString()
  File "angr/angr/knowledge_plugins/functions/function.py", line 388, in serialize_to_cmessage
    return FunctionParser.serialize(self)
  File "angr/angr/knowledge_plugins/functions/function_parser.py", line 58, in serialize
    edge.jumpkind = func_edge_type_to_pb(value)
TypeError: None has type NoneType, but expected one of: int, long

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "fuzz_driver.py", line 474, in <module>
    db.dump(db_file)
  File "angr/angr/angrdb/db.py", line 145, in dump
    self.update_dbinfo(session)
  File "/usr/lib/python3.6/contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "angr/angr/angrdb/db.py", line 40, in open_db
    raise AngrDBError(str(ex))
angr.errors.AngrDBError: None has type NoneType, but expected one of: int, long
```



**Environment Information.**
<!--
Many common issues are caused by problems with the local Python environment.
Before submitting, double-check that your versions of all modules in the angr suite (angr, cle, pyvex, ...) are up to date.
Please include the output of `python -m angr.misc.bug_report` here.
-->
latest version of angr with python3 (virtualenv)


**To Reproduce.**
<!--
Please include *both a script to reproduce the crash, and attach the binary used, if possible*
-->


**Additional context.**
<!--
Add any other context about the problem here.
-->

[adb_failed_bin.zip](https://github.com/angr/angr/files/4561800/adb_failed_bin.zip)





Discussion:

Resolving patch:
diff --git a/angr/knowledge_plugins/functions/function.py b/angr/knowledge_plugins/functions/function.py
--- a/angr/knowledge_plugins/functions/function.py
+++ b/angr/knowledge_plugins/functions/function.py
@@ -847,7 +847,7 @@ def _remove_fakeret(self, from_node, to_node):
         self._local_transition_graph = None
 
     def _return_from_call(self, from_func, to_node, to_outside=False):
-        self.transition_graph.add_edge(from_func, to_node, type='real_return', to_outside=to_outside)
+        self.transition_graph.add_edge(from_func, to_node, type='return', to_outside=to_outside)
         for _, _, data in self.transition_graph.in_edges(to_node, data=True):
             if 'type' in data and data['type'] == 'fake_return':
                 data['confirmed'] = True


Test patch: