Re: [Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-30 Thread Nick Coghlan
On 31 August 2016 at 05:06, Serhiy Storchaka wrote: > On 30.08.16 20:42, Nick Coghlan wrote: >> Given Serhiy's clarification that this is primarily a thread safety >> problem, I'm more supportive of the "PySlice_GetIndicesForObject" >> approach (since that can call all the

Re: [Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-30 Thread Serhiy Storchaka
On 30.08.16 20:42, Nick Coghlan wrote: On 28 August 2016 at 08:25, Terry Reedy wrote: Slicing can be made to malfunction and even crash with an 'evil' __index__ method. https://bugs.python.org/issue27867 The crux of the problem is this: PySlice_GetIndicesEx receives a slice

Re: [Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-30 Thread Nick Coghlan
On 28 August 2016 at 08:25, Terry Reedy wrote: > Slicing can be made to malfunction and even crash with an 'evil' __index__ > method. https://bugs.python.org/issue27867 > > The crux of the problem is this: PySlice_GetIndicesEx > receives a slice object and a sequence length.

Re: [Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-30 Thread Serhiy Storchaka
On 30.08.16 15:31, Dima Tisnek wrote: On 30 August 2016 at 14:13, Serhiy Storchaka wrote: 1. Detect length change and raise. It would be simpler solution. But I afraid that this can break third-party code that "just works" now. For example slicing a list "just works" if

Re: [Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-30 Thread Stefan Krah
On Tue, Aug 30, 2016 at 03:11:25PM +0200, Maciej Fijalkowski wrote: > It's more complicated - if the third party rely on the code working > when one thread slices while the other thread modifies that gives > implicit atomicity requirements. Those specific requirements are very > hard to maintain

Re: [Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-30 Thread Maciej Fijalkowski
On Tue, Aug 30, 2016 at 2:31 PM, Dima Tisnek wrote: > On 30 August 2016 at 14:13, Serhiy Storchaka wrote: >>> 1. Detect length change and raise. >> >> >> It would be simpler solution. But I afraid that this can break third-party >> code that "just works"

Re: [Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-30 Thread Dima Tisnek
On 30 August 2016 at 14:13, Serhiy Storchaka wrote: >> 1. Detect length change and raise. > > > It would be simpler solution. But I afraid that this can break third-party > code that "just works" now. For example slicing a list "just works" if step > is 1. It can return not

Re: [Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-30 Thread Serhiy Storchaka
On 28.08.16 01:25, Terry Reedy wrote: 0. Do nothing. The problem is not in pathological __index__. The problem is in executing Python code and releasing GIL. In multithread production code one thread can read a slice when other thread modifies a collection. In very very rare case it causes

Re: [Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-29 Thread Ethan Furman
On 08/28/2016 09:26 AM, Nick Coghlan wrote: On 28 August 2016 at 08:25, Terry Reedy wrote: Slicing can be made to malfunction and even crash with an 'evil' __index__ method. https://bugs.python.org/issue27867 The crux of the problem is this: PySlice_GetIndicesEx receives a

Re: [Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-28 Thread Nick Coghlan
On 28 August 2016 at 08:25, Terry Reedy wrote: > Slicing can be made to malfunction and even crash with an 'evil' __index__ > method. https://bugs.python.org/issue27867 > > The crux of the problem is this: PySlice_GetIndicesEx > receives a slice object and a sequence length.

[Python-Dev] What do we do about bad slicing and possible crashes (issue 27867)

2016-08-27 Thread Terry Reedy
Slicing can be made to malfunction and even crash with an 'evil' __index__ method. https://bugs.python.org/issue27867 The crux of the problem is this: PySlice_GetIndicesEx receives a slice object and a sequence length. Calling __index__ on the start, stop, and step components can mutate the