{"action":"created","issue":{"url":"https://api.github.com/repos/numpy/numpy/issues/7561","repository_url":"https://api.github.com/repos/numpy/numpy","labels_url":"https://api.github.com/repos/numpy/numpy/issues/7561/labels{/name}","comments_url":"https://api.github.com/repos/numpy/numpy/issues/7561/comments","events_url":"https://api.github.com/repos/numpy/numpy/issues/7561/events","html_url":"https://github.com/numpy/numpy/issues/7561","id":149510659,"number":7561,"title":"Crash on `array_dealloc` when running test suite","user":{"login":"tadeu","id":955251,"avatar_url":"https://avatars.githubusercontent.com/u/955251?v=3","gravatar_id":"","url":"https://api.github.com/users/tadeu","html_url":"https://github.com/tadeu","followers_url":"https://api.github.com/users/tadeu/followers","following_url":"https://api.github.com/users/tadeu/following{/other_user}","gists_url":"https://api.github.com/users/tadeu/gists{/gist_id}","starred_url":"https://api.github.com/users/tadeu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tadeu/subscriptions","organizations_url":"https://api.github.com/users/tadeu/orgs","repos_url":"https://api.github.com/users/tadeu/repos","events_url":"https://api.github.com/users/tadeu/events{/privacy}","received_events_url":"https://api.github.com/users/tadeu/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-19T16:18:57Z","updated_at":"2016-04-19T16:23:47Z","closed_at":null,"body":"This is happening when running the full test suite (`numpy.test('full', verbose=3)`) for NumPy v1.11.0 in win64 pydebug version.\r\n\r\nIt hangs right after printing `Test two arrays with different shapes are found not equal. ...`, which means it is probably on `test_utils.py`. When the tests there are run isolated, it does not crash (crashes only when running the full test suite).\r\n\r\nI've managed to attach a debugger, and this is the detailed call stack inside `multiarray_d.pyd`:\r\n\r\n```\r\n \tmultiarray_d.pyd!PyDataMem_FREE(void * ptr=0x00000000120034f0) Line 214\tC\r\n \tmultiarray_d.pyd!_npy_free_cache(void * p=0x00000000120034f0, unsigned __int64 nelem=0, unsigned int msz=1024, cache_bucket * cache=0x000007fee1bf7280, void (void *) * dealloc=0x000007fee1941540) Line 60\tC\r\n \tmultiarray_d.pyd!npy_free_cache(void * p=0x00000000120034f0, unsigned __int64 sz=0) Line 95\tC\r\n>\tmultiarray_d.pyd!array_dealloc(tagPyArrayObject * self=0x00000000126fa0c0) Line 428\tC\r\n \tpython27_d.dll!_Py_Dealloc(_object * op=0x00000000126fa0c0) Line 2263\tC\r\n \tpython27_d.dll!frame_dealloc(_frame * f=0x0000000004dc63d8) Line 460\tC\r\n \tpython27_d.dll!_Py_Dealloc(_object * op=0x0000000004dc63d8) Line 2263\tC\r\n \tpython27_d.dll!PyEval_EvalCodeEx(PyCodeObject * co=0x0000000002714b98, _object * globals=0x0000000000000002, _object * locals=0x0000000000000002, _object * * args=0x0000000000000000, int argcount=2, _object * * kws=0x0000000003a38118, int kwcount=0, _object * * defs=0x0000000000000000, int defcount=0, _object * closure=0x0000000000000000) Line 3594\tC\r\n```\r\n\r\nIt seems to be a \"HEAP CORRUPTION DETECTED\" error.\r\n\r\nHere is what is happening in detail:\r\n\r\n`npy_free_cache(fa->data, PyArray_NBYTES(self));` being called for array with refcount == 0, and nbytes == 0.\r\nInside `_npy_free_cache`, `nelem == 0`, `cache[nelem].available == 7 == NCACHE`, so it arrives at `dealloc(p)`, which is trying to `free` a probably already `free`d pointer.\r\n\r\nHere is `fa`:\r\n\r\n```\r\n0x00000000126fa0c0 {_ob_next=0x0000000000000000 <NULL> _ob_prev=0x0000000000000000 <NULL> ob_refcnt=...}\r\n    _ob_next: 0x0000000000000000 <NULL>\r\n    _ob_prev: 0x0000000000000000 <NULL>\r\n    ob_refcnt: 0\r\n    ob_type: 0x000007fee1b70f60 {multiarray_d.pyd!_typeobject PyArray_Type} {_ob_next=0x000000000254a698 {_ob_next=...} ...}\r\n    data: 0x00000000120034f0 \"\"\r\n    nd: 1\r\n    dimensions: 0x0000000013ccd250 {0}\r\n    strides: 0x0000000013ccd258 {4}\r\n    base: 0x0000000000000000 <NULL>\r\n    descr: 0x000007fee1b77720 {multiarray_d.pyd!_PyArray_Descr LONG_Descr} {_ob_next=0x0000000000000000 <NULL> ...}\r\n    flags: 1287\r\n    weakreflist: 0x0000000000000000 <NULL>\r\n```\r\n\r\n`fa->descr`:\r\n\r\n```\r\nfa->descr\r\n0x000007fee1b77720 {multiarray_d.pyd!_PyArray_Descr LONG_Descr} {_ob_next=0x0000000000000000 <NULL> ...}\r\n    _ob_next: 0x0000000000000000 <NULL>\r\n    _ob_prev: 0x0000000000000000 <NULL>\r\n    ob_refcnt: 1043\r\n    ob_type: 0x000007fee1b91fa0 {multiarray_d.pyd!_typeobject PyArrayDescr_Type} {_ob_next=0x00000000025670d8 {_ob_next=...} ...}\r\n    typeobj: 0x000007fee1bf3b40 {multiarray_d.pyd!_typeobject PyLongArrType_Type} {_ob_next=0x0000000002556fa8 {_ob_next=...} ...}\r\n    kind: 105 'i'\r\n    type: 108 'l'\r\n    byteorder: 61 '='\r\n    flags: 0 '\\0'\r\n    type_num: 7\r\n    elsize: 4\r\n    alignment: 4\r\n    subarray: 0x0000000000000000 <NULL>\r\n    fields: 0x000000001e3cd2d8 {python27_d.dll!_object _Py_NoneStruct} {_ob_next=0x0000000001e31cf8 {_ob_next=0x0000000001e32040 {...} ...} ...}\r\n    names: 0x0000000000000000 <NULL>\r\n    f: 0x000007fee1b775a0 {multiarray_d.pyd!PyArray_ArrFuncs _PyLong_ArrFuncs} {cast=0x000007fee1b775a0 {0x000007fee195a620 {multiarray_d.pyd!LONG_to_BOOL(void *, void *, __int64, void *, void *)}, ...} ...}\r\n    metadata: 0x0000000000000000 <NULL>\r\n    c_metadata: 0x0000000000000000 <NULL>\r\n    hash: -1299418611\r\n```\r\n\r\n```\r\n    [0]: 0x00000004\r\n    [1]: 0x00000000\r\n    [2]: 0x00342731\r\n    [3]: 0xfdfdfdfd\r\n    [4]: 0x00000000    <-- fa->data points here\r\n    [5]: 0x00000000\r\n    [6]: 0x0133e83a\r\n    [7]: 0x88000047\r\n    [8]: 0x04ca6990\r\n    [9]: 0x00000000\r\n    [10]: 0x132c2db0\r\n    [11]: 0x00000000\r\n    [12]: 0x00000000\r\n    [13]: 0x00000000\r\n    [14]: 0x00000000\r\n    [15]: 0x00000001\r\n    [16]: 0x00000004\r\n    [17]: 0x00000000\r\n    [18]: 0x00339900\r\n    [19]: 0xfdfdfdfd\r\n    [20]: 0x00000001\r\n    [21]: 0xfdfdfdfd\r\n    [22]: 0x0133e826\r\n ```\r\n"},"comment":{"url":"https://api.github.com/repos/numpy/numpy/issues/comments/212003726","html_url":"https://github.com/numpy/numpy/issues/7561#issuecomment-212003726","issue_url":"https://api.github.com/repos/numpy/numpy/issues/7561","id":212003726,"user":{"login":"charris","id":77272,"avatar_url":"https://avatars.githubusercontent.com/u/77272?v=3","gravatar_id":"","url":"https://api.github.com/users/charris","html_url":"https://github.com/charris","followers_url":"https://api.github.com/users/charris/followers","following_url":"https://api.github.com/users/charris/following{/other_user}","gists_url":"https://api.github.com/users/charris/gists{/gist_id}","starred_url":"https://api.github.com/users/charris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/charris/subscriptions","organizations_url":"https://api.github.com/users/charris/orgs","repos_url":"https://api.github.com/users/charris/repos","events_url":"https://api.github.com/users/charris/events{/privacy}","received_events_url":"https://api.github.com/users/charris/received_events","type":"User","site_admin":false},"created_at":"2016-04-19T16:23:47Z","updated_at":"2016-04-19T16:23:47Z","body":"Where did you get numpy?"}}