Issue7063
Created on 2009-10-05 08:12 by chuck, last changed 2009-10-05 12:52 by chuck.
| Messages (3) | |||
|---|---|---|---|
| msg93581 - (view) | Author: chuck (chuck) | Date: 2009-10-05 08:12 | |
While I was backporting the new buffer API to 2.7 I noticed some issues in array_ass_slice() in Modules/arraymodule.c in the python 3k branch. 1) Manual memory reallocation had been replaced by calls to array_resize. But I think when PyMem_RESIZE is called the pointer to the memory might change. So this now happens in array_resize, and the array->ob_item pointer changes but not it's local copy (item) in array_ass_slice(). 2) The function moves too much memory if the array size is increased: (Py_SIZE(a)-d-ihigh) items should be moved, because Py_SIZE(a) was already modified by array_resize, but the function moves (Py_SIZE(a)- ihigh) items. While 1) might go unnoticed, 2) definitely broke slice tests in a "segmentation fault"-way (in debug mode forbidden bits show the error). I tried to write a test, but I don't know how to trigger array_ass_slice() with a write access, as it is not in array_as_sequence anymore (like in 2.7). How is slicing handled now? |
|||
| msg93584 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * ![]() |
Date: 2009-10-05 09:01 | |
The array type also defines tp_as_mapping->mp_ass_subscript, which has priority in PyObject_SetItem(). A way to call array_ass_slice() is to use PySequence_SetItem(), but this is hard to trigger from python code (it should be possible with ctypes). |
|||
| msg93598 - (view) | Author: chuck (chuck) | Date: 2009-10-05 12:52 | |
The mp_ass_subscript function looks fine in contrast to array_ass_slice(). So if array_ass_slice() is not accessible from the outside and is only called with NULL as replacement parameter from the inside, I won't be able to cause trouble with those two issues. Still I think it's bad to keep buggy code around, even it is not used. Maybe array_ass_slice() should be changed to what it's used for: array_del_slice()? |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2009-10-05 12:52:16 | chuck | set | messages: + msg93598 |
| 2009-10-05 09:01:32 | amaury.forgeotdarc | set | nosy:
+ amaury.forgeotdarc messages: + msg93584 |
| 2009-10-05 08:12:28 | chuck | create | |
