Repository: angr/angr

Issue:
KeyError: 'Iop_Sqrt64F0x2'
**Describe the bug**
angr-management refuses to display certain functions.
The following exception is printed to the console:
```
Traceback (most recent call last):
  File "$HOME/angr-dev/angr-management/angrmanagement/ui/widgets/qfunction_table.py", line 227, in _on_function_selected
    self._selection_callback(selected_func)
  File "$HOME/angr-dev/angr-management/angrmanagement/ui/views/functions_view.py", line 41, in _on_function_selected
    self.workspace.on_function_selected(function)
  File "$HOME/angr-dev/angr-management/angrmanagement/ui/workspace.py", line 57, in on_function_selected
    self.views_by_category['disassembly'][0].display_function(function)
  File "$HOME/angr-dev/angr-management/angrmanagement/ui/views/disassembly_view.py", line 171, in display_function
    self._display_function(function)
  File "$HOME/angr-dev/angr-management/angrmanagement/ui/views/disassembly_view.py", line 343, in _display_function
    vr = self.workspace.instance.project.analyses.VariableRecoveryFast(the_func)
  File "$HOME/angr-dev/angr/angr/analyses/analysis.py", line 108, in __call__
    oself.__init__(*args, **kwargs)
  File "$HOME/angr-dev/angr/angr/analyses/variable_recovery/variable_recovery_fast.py", line 510, in __init__
    self._analyze()
  File "$HOME/angr-dev/angr/angr/analyses/forward_analysis.py", line 557, in _analyze
    self._analysis_core_graph()
  File "$HOME/angr-dev/angr/angr/analyses/forward_analysis.py", line 580, in _analysis_core_graph
    changed, output_state = self._run_on_node(n, job_state)
  File "$HOME/angr-dev/angr/angr/analyses/variable_recovery/variable_recovery_fast.py", line 587, in _run_on_node
    self._process_block(state, block)
  File "$HOME/angr-dev/angr/angr/analyses/variable_recovery/variable_recovery_fast.py", line 625, in _process_block
    processor.process(state, block=block, fail_fast=self._fail_fast)
  File "$HOME/angr-dev/angr/angr/analyses/variable_recovery/variable_recovery_fast.py", line 86, in process
    self._process(state, None, block=kwargs.pop('block', None))
  File "$HOME/angr-dev/angr/angr/analyses/variable_recovery/variable_recovery_fast.py", line 96, in _process
    super(SimEngineVR, self)._process(state, successors, block=block)
  File "$HOME/angr-dev/angr/angr/engines/light/engine.py", line 59, in _process
    self._process_Stmt()
  File "$HOME/angr-dev/angr/angr/engines/light/engine.py", line 74, in _process_Stmt
    self._handle_Stmt(stmt)
  File "$HOME/angr-dev/angr/angr/engines/light/engine.py", line 97, in _handle_Stmt
    getattr(self, handler)(stmt)
  File "$HOME/angr-dev/angr/angr/engines/light/engine.py", line 103, in _handle_WrTmp
    data = self._expr(stmt.data)
  File "$HOME/angr-dev/angr/angr/engines/light/engine.py", line 129, in _expr
    return getattr(self, handler)(expr)
  File "$HOME/angr-dev/angr/angr/engines/light/engine.py", line 149, in _handle_Unop
    simop = vex_operations[expr.op]
KeyError: 'Iop_Sqrt64F0x2'
```

**Environment Information**
```
angr environment report
=============================
Date: 2018-10-17 16:04:17.737115
Running in virtual environment at $HOME/.local/share/virtualenvs/angr
Platform: macosx-10.13-x86_64
Python version: 3.7.0 (default, Jun 29 2018, 20:13:13)
[Clang 9.1.0 (clang-902.0.39.2)]
######## angr #########
Python found it in $HOME/angr-dev/angr/angr
Pip version angr 8.18.10.5
Git info:
	Current commit 7ff4d0f9c105ea1cee3b0b043e15a2f4332a2e25 from branch hello
Could not resolve tracking branch or remote info!
######## ailment #########
Python found it in $HOME/.local/share/virtualenvs/angr/lib/python3.7/site-packages/ailment
Pip version ailment 8.18.10.5
Couldn't find git info
######## cle #########
Python found it in $HOME/angr-dev/cle/cle
Pip version cle 8.18.10.5
Git info:
	Current commit b84f8254d4eb62dc5a6036de44315a89f9abe132 from branch master
	Checked out from remote origin: git@github.com:angr/cle
######## pyvex #########
Python found it in $HOME/angr-dev/pyvex/pyvex
Pip version pyvex 8.18.10.5
Git info:
	Current commit cb441dcc5b32bd0aa21cc1ecf0e72b593a908f40 from branch master
	Checked out from remote origin: git@github.com:angr/pyvex
######## claripy #########
Python found it in $HOME/angr-dev/claripy/claripy
Pip version claripy 8.18.10.5
Git info:
	Current commit 49336fa3d3ad0ed941a47ab9ed8edbd86c2d2386 from branch master
	Checked out from remote origin: git@github.com:angr/claripy
######## archinfo #########
Python found it in $HOME/angr-dev/archinfo/archinfo
Pip version archinfo 8.18.10.5
Git info:
	Current commit 8d64061a1d9083b78a354a058db59bcdd9ebc61a from branch master
	Checked out from remote origin: git@github.com:angr/archinfo
######## ana #########
Python found it in $HOME/angr-dev/ana/ana
Pip version ana 0.5
Git info:
	Current commit 48657dc6500e33f5818b98003f1f179bfe03e1cc from branch master
	Checked out from remote origin: https://git:@github.com/zardus/ana
######## z3 #########
Python found it in $HOME/.local/share/virtualenvs/angr/lib/python3.7/site-packages/z3
Pip version not found!
Couldn't find git info
######## unicorn #########
Python found it in $HOME/.local/share/virtualenvs/angr/lib/python3.7/site-packages/unicorn
Pip version unicorn 1.0.1
Couldn't find git info
######### Native Module Info ##########
angr: None
unicorn: <CDLL '$HOME/.local/share/virtualenvs/angr/lib/python3.7/site-packages/unicorn/lib/libunicorn.dylib', handle 7fdf70e015a0 at 0x1036cf278>
pyvex: <cffi.api._make_ffi_library.<locals>.FFILibrary object at 0x102a7c518>
z3: <CDLL '$HOME/.local/share/virtualenvs/angr/lib/python3.7/site-packages/z3/lib/libz3.dylib', handle 7fdf73d8c520 at 0x10276d390>
```

**To Reproduce**
* Compile the following binary for x86_64:
```
	.globl main
main:
	vmovsd	0x8(%rdi),%xmm0
	vxorpd	%xmm8,%xmm8,%xmm8
	vmovsd	(%rdi),%xmm1
	vmulsd	%xmm0,%xmm0,%xmm4
	vmovsd	0x10(%rdi),%xmm2
	vmulsd	%xmm1,%xmm1,%xmm3
	vmulsd	%xmm2,%xmm2,%xmm6
	vaddsd	%xmm4,%xmm3,%xmm5
	vaddsd	%xmm6,%xmm5,%xmm0
	vucomisd	%xmm0,%xmm8
	vsqrtsd	%xmm0,%xmm0,%xmm7
	ja	else
	vmovapd	%xmm7,%xmm0
	retq
else:
	sub	$0x18,%rsp
	vmovsd	%xmm7,0x8(%rsp)
	callq	sqrt@plt
	vmovsd	0x8(%rsp),%xmm0
	add	$0x18,%rsp
	retq
```

* Load it into angr-management

* Try to open the `main` function

**Additional context**
Quick fix:
```
--- a/angr/engines/light/engine.py
+++ b/angr/engines/light/engine.py
@@ -146,8 +146,8 @@ class SimEngineLightVEX(SimEngineLight):

     def _handle_Unop(self, expr):
         handler = None
-        simop = vex_operations[expr.op]
-        if simop.op_attrs['conversion']:
+        simop = vex_operations.get(expr.op)
+        if simop is not None and simop.op_attrs.get('conversion'):
             handler = '_handle_Conversion'
         # Notice order of "Not" comparisons
         elif expr.op == 'Iop_Not1':
```



Discussion:

Resolving patch:
diff --git a/angr/engines/light/engine.py b/angr/engines/light/engine.py
--- a/angr/engines/light/engine.py
+++ b/angr/engines/light/engine.py
@@ -146,8 +146,10 @@ def _handle_Load(self, expr):
 
     def _handle_Unop(self, expr):
         handler = None
-        simop = vex_operations[expr.op]
-        if simop.op_attrs['conversion']:
+
+        # All conversions are handled by the Conversion handler
+        simop = vex_operations.get(expr.op)
+        if simop is not None and simop.op_attrs['conversion']:
             handler = '_handle_Conversion'
         # Notice order of "Not" comparisons
         elif expr.op == 'Iop_Not1':
@@ -159,8 +161,7 @@ def _handle_Unop(self, expr):
             return getattr(self, handler)(expr)
         else:
             self.l.error('Unsupported Unop %s.', expr.op)
-
-        return None
+            return None
 
     def _handle_Binop(self, expr):
         handler = None


Test patch: