title: Using ctypes to grab a pointer from a nullary function (segfault) x64
body: <p>I've reduced my problem to the following toy file and command:</p>
  
  <pre><code>// a.c --&gt; a.out, compiled with `gcc -fPIC -shared a.c`
  void* r2() {
    return NULL; // &lt;-- could be anything
  }
  </code></pre>
  
  <p><code>python -i -c 
  "from ctypes import *;
  clib = cdll.LoadLibrary('/home/soltanmm/tmp/a.out');
  CFUNCTYPE(c_void_p).in_dll(clib,'r2')()"</code></p>
  
  <p>^ results in a segfault in a call directly within <code>ffi_call_unix64</code>.</p>
  
  <p>I'm on an AMD64 Linux machine running Python 2.7. What am I doing wrong?</p>
  
  <h2>EDIT</h2>
  
  <p>To lend weight to how the pointers don't matter, a second example that segfaults:</p>
  
  <pre><code>// a.c --&gt; a.out
  int r1() {
    return 1;
  }
  </code></pre>
  
  <p><code>python -i -c 
  "from ctypes import *;
  clib = cdll.LoadLibrary('/home/soltanmm/tmp/a.out');
  CFUNCTYPE(c_int).in_dll(clib,'r1')()"</code></p>