pypy pythonnet call fails on PyPyClass_New

Issue #2504 resolved
Denis Akhiyarov
created an issue

Exception thrown at 0x1081C174 (libpypy-c.dll) in pypy.exe: 0xC0000005: Access violation reading location 0x00000004.

IntPtr s = Runtime.PyPyString_FromString("_temp");
IntPtr d = Runtime.PyPyDict_New();
IntPtr c = Runtime.PyPyClass_New(IntPtr.Zero, d, s);

Python 2.7.13 (3ecf4b9db0f5, Mar 16 2017, 21:26:47) [PyPy 5.8.0-alpha0 with MSC v.1500 32 bit] on win32

Comments (3)

  1. Denis Akhiyarov reporter

    Here are how the calls are defined in pythonnet:

    internal static IntPtr PyPyString_FromString(string value)
            {
                return PyPyString_FromStringAndSize(value, value.Length);
            }
    
    [DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
                ExactSpelling = true, CharSet = CharSet.Ansi)]
            internal unsafe static extern IntPtr
                PyPyString_FromStringAndSize(string value, int size);
    
    [DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
                ExactSpelling = true, CharSet = CharSet.Ansi)]
            internal unsafe static extern IntPtr
                PyPyDict_New();
    
    [DllImport(Runtime.dll, CallingConvention = CallingConvention.Cdecl,
                ExactSpelling = true, CharSet = CharSet.Ansi)]
            internal unsafe static extern IntPtr
                PyPyClass_New(IntPtr bases, IntPtr dict, IntPtr name);
    
  2. Log in to comment