Ticket #179 (closed enhancement: fixed)

Opened 19 months ago

Last modified 19 months ago

include syntax tree path in compiler crash output

Reported by: scoder Owned by: scoder
Priority: major Milestone: 0.11
Component: Error Reporting Keywords:
Cc:

Description

Stefan Behnel wrote:
> Robert Bradshaw wrote:
>> It would be really useful to have a mode/mechanism to get the  
>> position of the code when an error like this occurs. I can think of  
>> several ways to do it, but all would significantly impact speed.
> 
> Yes, I thought about that, too, a couple of times already. The stack traces
> are not very helpful, what you'd need is a dump of the syntax tree nodes
> that are along the trace path.
> 
> We could do that by catching all exceptions in Main.py, collecting all
> objects that belong to method calls in the stack trace, and dumping all
> that inherit from Node.
> 
> This won't work for compiled code, but exceptions inside the parser are
> rare anyway. Most of the compiler crashes I had to deal with so far were in
> Nodes or ExprNodes.
> 
> Something even simpler could work for transforms, where we control the
> traversal in framework code. Here, we could just catch all exceptions in
> visit() and dump the current tree path.

Change History

Changed 19 months ago by scoder

  • owner set to scoder
  • status changed from new to assigned

Changed 19 months ago by scoder

I added a more descriptive error message for compiler crashes in transforms for now:

 http://hg.cython.org/cython-devel/rev/7110f62bc826

Example (with a fake error that simply raises an exception somewhere):

$ python bin/cython tests/run/attr.pyx
Error converting Pyrex file to C:
------------------------------------------------------------
...                                                         
    2                                                       
    >>> b.spam.eggs.spam.i                                  
    4                                                       
"""                                                         

def f(b):
^        
------------------------------------------------------------

/home/sbehnel/source/Python/cython/cython-work/tests/run/attr.pyx:59:0: Compiler crash in AnalyseExpressionsTransform

ModuleNode.body = StatListNode(attr.pyx:1:0,
    gil_message = 'Operation',              
    is_literal = 0,                         
    is_name = 0)                            
StatListNode.stats[1] = DefNode(attr.pyx:59:0,
    gil_message = 'Operation',                
    is_literal = 0,                           
    is_name = 0,                              
    is_wrapper = 0,                           
    name = u'f',                              
    needs_closure = False,                    
    num_kwonly_args = 0,                      
    num_required_args = 1,                    
    num_required_kw_args = 0,                 
    pxd_locals = [...],                       
    reqd_kw_flags_cname = '0')                

Compiler crash traceback from this point on:
  File "/home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/Visitor.py", line 128, in visitchild
    result = self.visit(child)
  File "/home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/Visitor.py", line 45, in visit
    return handler_method(obj)
  File "/home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ParseTreeTransforms.py", line 744, in visit_FuncDefNode
    node.body.analyse_expressions(node.local_scope)
  File "/home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/Nodes.py", line 320, in analyse_expressions
    stat.analyse_expressions(env)
  File "/home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/Nodes.py", line 2730, in analyse_expressions
    self.analyse_types(env)
  File "/home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/Nodes.py", line 2823, in analyse_types
    self.rhs.analyse_types(env)
  File "/home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ExprNodes.py", line 2638, in analyse_types
    self.analyse_as_ordinary_attribute(env, target)
  File "/home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ExprNodes.py", line 2717, in analyse_as_ordinary_attribute
    self.analyse_attribute(env)
  File "/home/sbehnel/source/Python/cython/cython-work/Cython/Compiler/ExprNodes.py", line 2743, in analyse_attribute
    raise InternalError(None)
InternalError: Internal compiler error: None

As can be seen, it still lacks support for printing a tree path inside the node call stack. But it's a start.

Changed 19 months ago by scoder

  • status changed from assigned to closed
  • resolution set to fixed

Changed 19 months ago by robertwb

  • milestone changed from wishlist to 0.11
Note: See TracTickets for help on using tickets.