Skip to content

Calling len() or __len()__ on a System.Array after a domain reload causes Exceptions and/or crashes #2171

@BadSingleton

Description

@BadSingleton

Environment

  • Pythonnet version: 3.0.0/3.0.1
  • Python version: 3.10.6
  • Operating System: windows 10
  • .NET Runtime: mono/Unity, but repros on non-mono too.

Details

Calling len() or __len()__ on an array (like string[]) object after a domain reload results in either a DomainUnloadedException or an AccessViolationException (and sometimes, other types of exceptions). In Unity, this always result in a crash.

I've tried to debug, but couldn't find a solid lead. My hunch is that the slot doesn't get properly set/reset on domain reload.

The example is easier to see with a unit test: https://github.com/Unity-Technologies/pythonnet/tree/array_len_reload

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