Opened 4 years ago

Closed 4 years ago

#578 closed defect (fixed)

crash in Py3 with non-sliceable slices

Reported by: robertwb Owned by: scoder
Priority: critical Milestone: 0.14
Component: Code Generation Keywords:
Cc:

Description

I believe

range(10)[1:2]

is enough to trigger it.

Change History (5)

comment:1 Changed 4 years ago by robertwb

  • Priority changed from major to critical

comment:2 Changed 4 years ago by scoder

I tried cythonising

range(10)[1:2]
1[2:3]

which generates a C file without crashing the compiler. However, when I run it, I get a crash in PySequence_GetSlice() on the following code:

    mp = s->ob_type->tp_as_mapping;
    if (mp->mp_subscript) {

The mp pointer is NULL. Clearly a bug in CPython, introduced in the Py3 series.

http://bugs.python.org/issue9834

comment:3 Changed 4 years ago by scoder

  • Summary changed from compiler crash in Py3 with non-sliceable slices to crash in Py3 with non-sliceable slices

As a workaround, we could replace the calls to PySequence_GetSlice by a macro call that expands to an additional s->ob_type->tp_as_mapping check before the call for the affected CPython versions. Let's expect this to be fixed in the next official releases.

comment:4 Changed 4 years ago by scoder

  • Owner changed from somebody to scoder
  • Status changed from new to assigned

comment:5 Changed 4 years ago by scoder

  • Milestone changed from wishlist to 0.13.1
  • Resolution set to fixed
  • Status changed from assigned to closed

Bug will be fixed in releases after CPython 3.1.2, Cython work-around is implemented here:

http://hg.cython.org/cython-devel/rev/142faf1058ff

Note: See TracTickets for help on using tickets.