Skip to content
This repository has been archived by the owner on Sep 14, 2018. It is now read-only.

Crash when compiling dictionary comprehension #1196

Closed
kunom opened this issue Apr 29, 2015 · 1 comment
Closed

Crash when compiling dictionary comprehension #1196

kunom opened this issue Apr 29, 2015 · 1 comment
Labels
Milestone

Comments

@kunom
Copy link
Contributor

kunom commented Apr 29, 2015

The IronPython 2.7.5 runtime crashes when compiling the script below. The culprit seems to be the lambda statement inside of the dictionary comprehension. The repetitive use of 'i' as variable name doesn't seem to matter.

import itertools

def foo(coll):
    def _extract_key(i):
        return i

    print {k:list(g) for k, g in itertools.groupby(coll.iteritems(), lambda i: _extract_key(i))}

foo({1:2, 3:4})
D:\mytemp>ipy -V
IronPython 2.7 2.7.5.0 on .NET 4.0.30319.34209

D:\mytemp>ipy -X:ExceptionDetail dict-comprehension-bug.py
Specified method is not supported.
   at IronPython.Compiler.Ast.ScopeStatement.GetParentClosureTuple()
   at IronPython.Compiler.Ast.ScopeStatement.CreateVariables(ReadOnlyCollectionBuilder`1 locals, List`1 init)
   at IronPython.Compiler.Ast.ComprehensionScope.AddVariables(Expression expression)
   at IronPython.Compiler.Ast.DictionaryComprehension.Reduce()
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileExtensionExpression(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileMethodCallExpression(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileAsVoid(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockStart(BlockExpression node)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockExpression(Expression expr, Boolean asVoid)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileAsVoid(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockStart(BlockExpression node)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockExpression(Expression expr, Boolean asVoid)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.Compile(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileExtensionExpression(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileAsVoid(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockExpression(Expression expr, Boolean asVoid)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.Compile(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileExtensionExpression(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileAsVoid(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockExpression(Expression expr, Boolean asVoid)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.Compile(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileTryExpression(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileAsVoid(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockExpression(Expression expr, Boolean asVoid)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileAsVoid(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockStart(BlockExpression node)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockExpression(Expression expr, Boolean asVoid)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileAsVoid(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockExpression(Expression expr, Boolean asVoid)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileAsVoid(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockExpression(Expression expr, Boolean asVoid)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileAsVoid(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockStart(BlockExpression node)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileBlockExpression(Expression expr, Boolean asVoid)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileNoLabelPush(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.Compile(Expression expr)
   at Microsoft.Scripting.Interpreter.LightCompiler.CompileTop(LightLambdaExpression node)
   at Microsoft.Scripting.Ast.LightLambdaExpression.Compile(Int32 compilationThreshold)
   at IronPython.Runtime.FunctionCode.CompileLambda(LightLambdaExpression code, EventHandler`1 handler)
   at IronPython.Runtime.FunctionCode.UpdateDelegate(PythonContext context, Boolean forceCreation)
   at IronPython.Runtime.FunctionCode.LazyCompileFirstTarget(PythonFunction function)
   at IronPython.Compiler.PythonCallTargets.OriginalCallTarget1(PythonFunction function, Object arg0)
   at IronPython.Runtime.FunctionCaller`1.Call1(CallSite site, CodeContext context, Object func, T0 arg0)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2)
   at Microsoft.Scripting.Interpreter.FuncCallInstruction`6.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3)
   at IronPython.Compiler.Ast.CallExpression.Invoke1Instruction.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
   at Microsoft.Scripting.Interpreter.LightLambda.Run1[T0,TRet](T0 arg0)
   at IronPython.Compiler.RuntimeScriptCode.InvokeTarget(Scope scope)
   at IronPython.Compiler.RuntimeScriptCode.Run(Scope scope)
   at IronPython.Hosting.PythonCommandLine.RunFileWorker(String fileName)
   at IronPython.Hosting.PythonCommandLine.RunFile(String fileName)
SystemError: Specified method is not supported.
@kunom
Copy link
Contributor Author

kunom commented May 6, 2015

This issue also applies to set comprehensions, but not to list comprehensions, since list comprehensions do not have their private scope.

In fact, the ComprehensionScope class should overload ScopeStatement.GetParentClosureTuple().

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants