Skip to content

Infinite loop/crash in root.LoadNames() #603

Closed

Description

@barrybriggs

Environment

  • Pythonnet version: 2.3
  • Python version: 3.6
  • Operating System: Windows

Details

(Pythonnet newbie). Trying to embed Pythonnet in a simple WPF app. Built Python.Runtime from source setting PYTHON3 and PYTHON36 on x64. Gets to GetCLRModule in importhook.cs and gets in infinite loop in root.LoadNames() line 98, ultimately crashes.

Activity

  1. den-run-ai commented on Jan 23, 2018

    @den-run-ai
    Contributor

    @barrybriggs how can someone reproduce this issue? Did you look at troubleshooting and installation wikis? Does this happen without WPF (in console)?

  2. barrybriggs commented on Jan 23, 2018

    @barrybriggs
    Author

    Thanks for the quick response. The code is very, very simple -- click on a WPF menu and the click handler calls PythonEngine.Initialize(). When I trace into root.LoadNames() there is the following code:

            {
                ManagedType m = null;
                foreach (string name in AssemblyManager.GetNames(_namespace))
                {
                    cache.TryGetValue(name, out m);
                    if (m == null)
                    {
                        ManagedType attr = GetAttribute(name, true);
                    }
                }
            }
    

    The 'names' that it loads are: "FXAssembly", "ThisAssembly", "AssemblyRef", "", and then it starts trying to load what seems like types "_StaticArrayInitTypeSize=6" and then 8, and so on. It does this forever.

    I have a feeling this may be because there is some required assembly or .py file or something like that it's looking for, but I can't find it.

    UPDATE: I should add in my bin\debug folder there are: clr.py, clr.pyd, Python.Runtime.dll, python3.dll and python36.dll ... missing anything?

  3. den-run-ai commented on Jan 24, 2018

    @den-run-ai
    Contributor

    Do the demo apps work for you? Your example is still not reproducible.

  4. barrybriggs commented on Jan 24, 2018

    @barrybriggs
    Author

    npython loads. However, the demo apps do not run (assuming I typed the command correctly, which, as a Python newbie, I may not have):

    >>> exec(open("Z:\demo\helloform.py").read())
    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "<string>", line 8, in <module>
    ModuleNotFoundError: No module named 'System'
    

    PATH and PYTHONHOME are set correctly.

  5. dmitriyse commented on Jan 24, 2018

    @dmitriyse
    Contributor

    Please try "featured" branch. At least problems with "_StaticArrayInitTypeSize=6" types are eliminated.

  6. barrybriggs commented on Jan 24, 2018

    @barrybriggs
    Author

    @dmitriyse That seems to have cured the problem. Thanks!!

  7. den-run-ai commented on Jan 28, 2018

    @den-run-ai
    Contributor

    @dmitriyse what is the corresponding commit that fixes this "_StaticArrayInitTypeSize=6". I have not seen this issue before.

  8. dmitriyse commented on Jan 28, 2018

    @dmitriyse
    Contributor

    This is the corresponding PR #528

  9. den-run-ai commented on Nov 14, 2018

    @den-run-ai
    Contributor

    closed by #723

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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