IronLanguages / ironpython3

Implementation of Python 3.x for .NET Framework that is built on top of the Dynamic Language Runtime.
Apache License 2.0
2.51k stars 290 forks source link

Changing __bases__ attribute in issubclass() causes core dumped #1608

Open xiaxinmeng opened 1 year ago

xiaxinmeng commented 1 year ago

In the following example test.py, we define two classes A and B. If we change 'bases' in issubclass, ironpython crashes

test.py:

class A:
    @property
    def __bases__(self):
        return (self,)

class B:
    @property
    def __bases__(self):
        return (A(),)

assert issubclass(B(), int) #crash

Error message:

>>'ironpython/ironpython3/bin/Debug/net6.0/ipy' test.py
...
   at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Microsoft.Scripting.Runtime.Scope)
   at IronPython.Compiler.RuntimeScriptCode.Run(Microsoft.Scripting.Runtime.Scope)
   at IronPython.Hosting.PythonCommandLine.RunFileWorker(System.String)
   at IronPython.Hosting.PythonCommandLine.RunFile(System.String)
   at Microsoft.Scripting.Hosting.Shell.CommandLine.Run()
   at IronPython.Hosting.PythonCommandLine.Run()
   at Microsoft.Scripting.Hosting.Shell.CommandLine.Run(Microsoft.Scripting.Hosting.ScriptEngine, Microsoft.Scripting.Hosting.Shell.IConsole, Microsoft.Scripting.Hosting.Shell.ConsoleOptions)
   at Microsoft.Scripting.Hosting.Shell.ConsoleHost.RunCommandLine()
   at Microsoft.Scripting.Hosting.Shell.ConsoleHost.ExecuteInternal()
   at PythonConsoleHost.ExecuteInternal()
   at Microsoft.Scripting.Hosting.Shell.ConsoleHost.Execute()
   at Microsoft.Scripting.Hosting.Shell.ConsoleHost.Run(System.String[])
   at PythonConsoleHost.Main(System.String[])
Aborted (core dumped)

System info: ironpython3-debug(main branch):IronPython 3.4.0b1 DEBUG (3.4.0.0010)[.NETCoreApp,Version=v6.0 on .NET 6.0.11 (64-bit)] on linux operating system: Ubuntu 18.04.6 LTS

slozier commented 1 year ago

This one seems to hang on CPython.