Repository: angr/angr

Issue:
AttributeError: 'NoneType' object has no attribute 'addr'
### Description

```
Traceback (most recent call last):
  File "D:\hui\self\capstone_test2\angr\test1.py", line 4, in <module>
    project = angr.Project(r'D:\\hui\\self\\games\\luaForRizin.exe')
  File "D:\hui\self\capstone_test2\venv\lib\site-packages\angr\analyses\analysis.py", line 216, in __call__
    r = w(*args, **kwargs)
  File "D:\hui\self\capstone_test2\venv\lib\site-packages\angr\analyses\analysis.py", line 201, in wrapper
    oself.__init__(*args, **kwargs)
  File "D:\hui\self\capstone_test2\venv\lib\site-packages\angr\analyses\cfg\cfg_fast.py", line 844, in __init__
    self._analyze()
  File "D:\hui\self\capstone_test2\venv\lib\site-packages\angr\analyses\forward_analysis\forward_analysis.py", line 247, in _analyze
    self._analysis_core_baremetal()
  File "D:\hui\self\capstone_test2\venv\lib\site-packages\angr\analyses\forward_analysis\forward_analysis.py", line 390, in _analysis_core_baremetal
    self._process_job_and_get_successors(job_info)
  File "D:\hui\self\capstone_test2\venv\lib\site-packages\angr\analyses\forward_analysis\forward_analysis.py", line 408, in _process_job_and_get_successors
    successors = self._get_successors(job)
  File "D:\hui\self\capstone_test2\venv\lib\site-packages\angr\analyses\cfg\cfg_fast.py", line 1341, in _get_successors
    jobs = self._scan_block(job)
  File "D:\hui\self\capstone_test2\venv\lib\site-packages\angr\analyses\cfg\cfg_fast.py", line 1885, in _scan_block
    entries = self._scan_procedure(cfg_job, current_func_addr)
  File "D:\hui\self\capstone_test2\venv\lib\site-packages\angr\analyses\cfg\cfg_fast.py", line 1951, in _scan_procedure
    self.functions.contains_addr(cfg_job.src_node.addr)
AttributeError: 'NoneType' object has no attribute 'addr'
```


### Steps to reproduce the bug

example bin: 
[luaForRizin.zip](https://github.com/angr/angr/files/14659017/luaForRizin.zip)

just one line:

```
import angr
project = angr.Project(r'luaForRizin.exe')
```





### Environment

angr environment report
=============================                                                                   
Date: 2024-03-20 09:03:41.914715                                                                
Running in virtual environment at D:\hui\self\capstone_test2\venv                               
Platform: win-amd64                                                                             
Python version: 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]
######## angr #########                                                                         
Python found it in D:\hui\self\capstone_test2\venv\lib\site-packages\angr\__init__.py           
Pip version angr 9.2.94
Git info:
        Current commit 3898d960b8cbb9eaa9d58667053c1a9ca54426d3 from branch master
        Checked out from remote gitee: https://gitee.com/weituotian/python-asm.git
######## ailment #########
Python found it in D:\hui\self\capstone_test2\venv\lib\site-packages\ailment\__init__.py
Pip version ailment 9.2.94
Git info:
        Current commit 3898d960b8cbb9eaa9d58667053c1a9ca54426d3 from branch master
        Checked out from remote gitee: https://gitee.com/weituotian/python-asm.git
######## cle #########
Python found it in D:\hui\self\capstone_test2\venv\lib\site-packages\cle\__init__.py
Pip version cle 9.2.94
Git info:
        Current commit 3898d960b8cbb9eaa9d58667053c1a9ca54426d3 from branch master
        Checked out from remote gitee: https://gitee.com/weituotian/python-asm.git
######## pyvex #########
Python found it in D:\hui\self\capstone_test2\venv\lib\site-packages\pyvex\__init__.py
Pip version pyvex 9.2.94
Git info:
        Current commit 3898d960b8cbb9eaa9d58667053c1a9ca54426d3 from branch master
        Checked out from remote gitee: https://gitee.com/weituotian/python-asm.git
######## claripy #########
Python found it in D:\hui\self\capstone_test2\venv\lib\site-packages\claripy\__init__.py
Pip version claripy 9.2.94
Git info:
        Current commit 3898d960b8cbb9eaa9d58667053c1a9ca54426d3 from branch master
        Checked out from remote gitee: https://gitee.com/weituotian/python-asm.git
######## archinfo #########
Python found it in D:\hui\self\capstone_test2\venv\lib\site-packages\archinfo\__init__.py
Pip version archinfo 9.2.94
Git info:
        Current commit 3898d960b8cbb9eaa9d58667053c1a9ca54426d3 from branch master
        Checked out from remote gitee: https://gitee.com/weituotian/python-asm.git
######## z3 #########
Python found it in D:\hui\self\capstone_test2\venv\lib\site-packages\z3\__init__.py
Pip version z3-solver 4.10.2.0
Git info:
        Current commit 3898d960b8cbb9eaa9d58667053c1a9ca54426d3 from branch master
        Checked out from remote gitee: https://gitee.com/weituotian/python-asm.git
######## unicorn #########
Python found it in D:\hui\self\capstone_test2\venv\lib\site-packages\unicorn\__init__.py
Pip version unicorn 2.0.1.post1
Git info:
        Current commit 3898d960b8cbb9eaa9d58667053c1a9ca54426d3 from branch master
        Checked out from remote gitee: https://gitee.com/weituotian/python-asm.git
######### Native Module Info ##########
angr: <CDLL 'D:\hui\self\capstone_test2\venv\lib\site-packages\angr\lib\angr_native.dll', handle 7ffadd7b0000 at 0x76843a0>
unicorn: <CDLL 'D:\hui\self\capstone_test2\venv\lib\site-packages\unicorn\lib\unicorn.dll', handle 7ffaf4d60000 at 0x57ca1a0>
pyvex: <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x0000000004DF7310>
z3: <CDLL 'D:\hui\self\capstone_test2\venv\Lib\site-packages\z3\lib\libz3.dll', handle 7ffaf56c0000 at 0x488d120>

### Additional context

_No response_


Discussion:
```
project = angr.Project(r'luaForRizin.exe', load_options={'auto_load_libs': False})
```
is good for me

Resolving patch:
diff --git a/angr/analyses/cfg/cfg_fast.py b/angr/analyses/cfg/cfg_fast.py
--- a/angr/analyses/cfg/cfg_fast.py
+++ b/angr/analyses/cfg/cfg_fast.py
@@ -1948,7 +1948,8 @@ def _scan_procedure(self, cfg_job, current_func_addr) -> List[CFGJob]:
         entries: List[CFGJob] = []
 
         if (
-            self.functions.contains_addr(cfg_job.src_node.addr)
+            cfg_job.src_node is not None
+            and self.functions.contains_addr(cfg_job.src_node.addr)
             and self.functions[cfg_job.src_node.addr].is_default_name
             and cfg_job.src_node.addr not in self.kb.labels
             and cfg_job.jumpkind == "Ijk_Boring"
@@ -3561,14 +3562,16 @@ def _clean_pending_exits(self):
     # Graph utils
     #
 
-    def _graph_add_edge(self, cfg_node, src_node, src_jumpkind, src_ins_addr, src_stmt_idx):
+    def _graph_add_edge(
+        self, cfg_node: CFGNode, src_node: Optional[CFGNode], src_jumpkind: str, src_ins_addr: int, src_stmt_idx: int
+    ):
         """
         Add edge between nodes, or add node if entry point
 
-        :param CFGNode cfg_node: node which is jumped to
-        :param CFGNode src_node: node which is jumped from none if entry point
-        :param str src_jumpkind: what type of jump the edge takes
-        :param int or str src_stmt_idx: source statements ID
+        :param cfg_node: node which is jumped to
+        :param src_node: node which is jumped from none if entry point
+        :param src_jumpkind: what type of jump the edge takes
+        :param src_stmt_idx: source statements ID
         :return: None
         """
 


Test patch: