ironpython3 icon indicating copy to clipboard operation
ironpython3 copied to clipboard

Recusive call of except branch in "yield from" crashes IronPython

Open xiaxinmeng opened this issue 3 years ago • 1 comments

See the following two examples. The only difference lie in except branch. test1.py can work well on IronPython. However,test2.py crashes IronPython.

test1.py

def foo():
    try:
        print(new)
        for i in range(100):
            yield i
    except:
        foo()

m = foo()
for i in m:
    print(i)

test2.py


def foo():
    try:
        print(new)
        for i in range(100):
            yield i
    except:
        yield from foo()

m = foo()
for i in m:
    print(i)

Crash Report:

.... in <5cd2739cd27844619789a1aa1ffdb0b0>:0 at IronPython.Hosting.PythonCommandLine.RunFileWorker (System.String fileName) [0x000e5] in <5cd2739cd27844619789a1aa1ffdb0b0>:0 at IronPython.Hosting.PythonCommandLine.RunFile (System.String fileName) [0x0000f] in <5cd2739cd27844619789a1aa1ffdb0b0>:0 at Microsoft.Scripting.Hosting.Shell.CommandLine.Run () [0x0003a] in <252827dbc7924637ba1c8c95b5f54810>:0 at IronPython.Hosting.PythonCommandLine.Run () [0x000d8] in <5cd2739cd27844619789a1aa1ffdb0b0>:0 at Microsoft.Scripting.Hosting.Shell.CommandLine.Run (Microsoft.Scripting.Hosting.ScriptEngine engine, Microsoft.Scripting.Hosting.Shell.IConsole console, Microsoft.Scripting.Hosting.Shell.ConsoleOptions options) [0x0003c] in <252827dbc7924637ba1c8c95b5f54810>:0 at Microsoft.Scripting.Hosting.Shell.ConsoleHost.RunCommandLine () [0x00053] in <252827dbc7924637ba1c8c95b5f54810>:0 at Microsoft.Scripting.Hosting.Shell.ConsoleHost.ExecuteInternal () [0x00051] in <252827dbc7924637ba1c8c95b5f54810>:0 at PythonConsoleHost.ExecuteInternal () [0x00025] in <9cafe2448f474c41b81ba0c1d71815eb>:0 at Microsoft.Scripting.Hosting.Shell.ConsoleHost.Execute () [0x00032] in <252827dbc7924637ba1c8c95b5f54810>:0 at Microsoft.Scripting.Hosting.Shell.ConsoleHost.Run (System.String[] args) [0x0015b] in <252827dbc7924637ba1c8c95b5f54810>:0 at PythonConsoleHost.Main (System.String[] args) [0x00020] in <9cafe2448f474c41b81ba0c1d71815eb>:0

System

IronPython 3.4.0a1 (3.4.0.0001) [.NETFramework,Version=v4.6 on Mono 6.12.0.122 (64-bit)] on linux

xiaxinmeng avatar Aug 03 '21 05:08 xiaxinmeng

This one also crashes CPython (3.9.5). Note that your two examples are not equivalent, the first one should be:

def foo():
    try:
        print(new)
        for i in range(100):
            yield i
    except:
        for x in foo():
            yield x

m = foo()
for i in m:
    print(i)

which also crashes IronPython and CPython.

slozier avatar Aug 04 '21 13:08 slozier