Skip to content

Access Violation when using 32bit version of python #1729

Closed
@SillieWous

Description

@SillieWous

Environment

  • Pythonnet version: 3.0.0-preview2021-12-25
  • Python version: 3.9.10
  • Operating System: Windows 10
  • .NET Runtime: 4.7.2

Details

  • Describe what you were trying to get done.

Embed python into C# using 32bit python.

Example assumes python3.9.10 32bit embed to be extracted to ./python

Python.Runtime.Runtime.PythonDLL = "./python/python39.dll";

Python.Runtime.PythonEngine.PythonHome = ./python/python39.dll;
Python.Runtime.PythonEngine.PythonPath = $"{PythonEngine.PythonPath}{Path.PathSeparator}.";

Python.Runtime.PythonEngine.Initialize();

Last line causes an access violation after preview2021-12-25 (preview2021-12-03 works).
python3.9.10 64bit embed version of python does not cause the same issue.

  • If there was a crash, please include the traceback here.
   System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at Python.Runtime.Runtime.PyType_FromSpecWithBases(NativeTypeSpec& spec, BorrowedReference bases)
   at Python.Runtime.PyType.FromSpec(TypeSpec spec, PyTuple bases)
   at Python.Runtime.TypeManager.CreateMetatypeWithGCHandleOffset()
   at Python.Runtime.TypeManager.CreateMetaType(Type impl, SlotsHolder& slotsHolder)
   at Python.Runtime.MetaType.Initialize()
   at Python.Runtime.Runtime.Initialize(Boolean initSigs)
   at Python.Runtime.PythonEngine.Initialize(IEnumerable`1 args, Boolean setSysArgv, Boolean initSigs)
   at Python.Runtime.PythonEngine.Initialize()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions