Skip to content

System.AccessViolationException for latest verion (3.0.0-preview2022-04-03) #1748

@zydjohnHotmail

Description

@zydjohnHotmail

Environment

  • Pythonnet version: 3.0.0-preview2022-04-03
  • Python version: 3.9.7
  • Operating System: Windows 10 (version 21H2)
  • .NET Runtime: 5.0

Details

  • Describe what you were trying to get done.

    Run the example C# program.

  • What commands did you run to trigger this issue? If you can provide a
    Minimal, Complete, and Verifiable example
    this will help us understand the issue.

using Python.Runtime;
using System;
using System.Collections.Generic;

namespace PythonCondaEnvironment
{
    internal class Program
    {
        static void Main(string[] args)
        { 
            using (Py.GIL())
            {
                dynamic np = Py.Import("numpy");
                Console.WriteLine(np.cos(np.pi * 2));

                dynamic sin = np.sin;
                Console.WriteLine(sin(5));

                double c = (double)(np.cos(5) + sin(5));
                Console.WriteLine(c);

                dynamic a = np.array(new List<float> { 1, 2, 3 });
                Console.WriteLine(a.dtype);

                dynamic b = np.array(new List<float> { 6, 5, 4 }, dtype: np.int32);
                Console.WriteLine(b.dtype);

                Console.WriteLine(a * b);
                Console.ReadKey();
            }
        }
    }
}
  • If there was a crash, please include the traceback here.
System.AccessViolationException
  HResult=0x80004003
  Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
  Source=<Cannot evaluate the exception source>
  StackTrace:
<Cannot evaluate the exception stack trace>

Note: the above code works for last version: 3.0.0-preview2022-03-03, but for this version: 3.0.0-preview2022-04-03, it is not working any more!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions