title: Pydev -- attach to python_d process (Python debug build) not working
body: <p>On Windows 7 I have Eclipse Neon (4.6.3) with Liclipse/PyDev, and I am using a custom 64-bit debug build of Python 2.7.13 (python_d.exe, built with Visual Studio using pcbuild.sln).  For the most part, this debug build of Python works with PyDev -- I can configure it as an interpreter and make run/debug sessions.  However, the "Attach to Process" feature does not work.  If I have a "python_d" process running somewhere on the system and try "Attach to Process" in PyDev, the following happens:</p>
  
  <ul>
  <li>The "Process output" dialog window shows the following:</li>
  </ul>
  
  <p><code>Connecting to 64 bits target
  Injecting dll
  Dll injected
  Allocating code in target process
  Writing code in target process
  Allocating return value memory in target process
  Injecting code to target process
  Waiting for code to complete
  Attach finished successfully.
  [127156 refs]
  Process finished with exitValue: 0</code></p>
  
  <ul>
  <li>A Windows crash dialog appears saying: "python_d.exe has stopped working"</li>
  <li>The "python_d" process to which I was attempting to attach gets this message in its output and then crashes: <code>Fatal Python error: UNREF invalid object</code></li>
  </ul>
  
  <p>In contrast, the attach mechanism works when I use a regular installed release of Python (which I have configured as a separate interpreter in PyDev).</p>
  
  <p>Are debug builds of Python supposed to work with the PyDev debugger attach mechanism?  Is this a bug in PyDev?  Could PyDev be improperly using a DLL that is only supposed to be used with Release builds of Python?  Does PyDev need to be built from source in a different way in order to support debug builds of Python for this purpose?</p>