Visitar URL original
Crash on shutdown when embedding Python in C# · Issue #1831 · pythonnet/pythonnet · GitHub
Skip to content

Crash on shutdown when embedding Python in C# #1831

Description

@BadSingleton

Environment

  • Pythonnet version: a80c685
  • Python version: 3.9.10
  • Operating System: Windows (probably others too)
  • .NET Runtime: mono/Unity

Details

Using the Python for Unity package with at a commit hash later or equal to the one above, pythonnet causes a crash on Shutdown. I've traced the issue to this PR: #1780 which is cause by checking a Python internal without holding the GIL; which the shutdown process isn't doing (or at least not at this point).

Activity

  1. changed the title [-]Crash on when embedding Python in C#[/-] [+]Crash on shutdown when embedding Python in C#[/+] on Jun 23, 2022
  2. filmor commented on Jun 23, 2022

    @filmor
    Member

    Is the Exceptions.ErrorOccurred() the culprit? Does it work if that whole section is put in a using (Py.GIL) scope?

  3. BadSingleton commented on Jun 23, 2022

    @BadSingleton
    ContributorAuthor

    It is the culprit. I'm unsure if it is totally advisable; PR incoming; grabbing the GIL only when embedded.

  4. Martin-Molinero commented on Jun 24, 2022

    @Martin-Molinero
    Contributor

    Just adding to this: we are seeing a similar segmentation fault while shutting down, only while debugging for same reason. Manually shutting down seems to avoid the seg fault QuantConnect/Lean#6439

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