{"action":"opened","issue":{"url":"https://api.github.com/repos/arrayfire/arrayfire/issues/586","labels_url":"https://api.github.com/repos/arrayfire/arrayfire/issues/586/labels{/name}","comments_url":"https://api.github.com/repos/arrayfire/arrayfire/issues/586/comments","events_url":"https://api.github.com/repos/arrayfire/arrayfire/issues/586/events","html_url":"https://github.com/arrayfire/arrayfire/issues/586","id":69438306,"number":586,"title":"Cannot destroy af_array handle after calling af_print","user":{"login":"umar456","id":457510,"avatar_url":"https://avatars.githubusercontent.com/u/457510?v=3","gravatar_id":"","url":"https://api.github.com/users/umar456","html_url":"https://github.com/umar456","followers_url":"https://api.github.com/users/umar456/followers","following_url":"https://api.github.com/users/umar456/following{/other_user}","gists_url":"https://api.github.com/users/umar456/gists{/gist_id}","starred_url":"https://api.github.com/users/umar456/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/umar456/subscriptions","organizations_url":"https://api.github.com/users/umar456/orgs","repos_url":"https://api.github.com/users/umar456/repos","events_url":"https://api.github.com/users/umar456/events{/privacy}","received_events_url":"https://api.github.com/users/umar456/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-04-19T16:03:19Z","updated_at":"2015-04-19T16:03:19Z","closed_at":null,"body":"Cannot call af_destroy on an af_array handle after it has been passed to af_print. Calling other functions with the same handle seems to be working.\r\n\r\n```cpp\r\n#include <arrayfire.h>\r\n#include <cstdio>\r\n#include <cstdlib>\r\n#include <vector>\r\n#include <cassert>\r\n\r\nusing namespace af;\r\n\r\nint main(int argc, char *argv[])\r\n{\r\n    try {\r\n        af::info();\r\n\r\n        std::vector<int> data(100, 10);\r\n        af_array dataArray;\r\n        dim_type dims[] = {4, 25};\r\n        af_create_array(&dataArray, &data.front(), 2, dims, s32);\r\n\r\n        af_print(dataArray);\r\n\r\n        //works\r\n        //double val, imag;\r\n        //assert(AF_SUCCESS == af_sum_all(&val, &imag, dataArray));\r\n        //printf(\"after sum: %f\\n\", val);\r\n\r\n        //fails\r\n        assert(AF_SUCCESS == af_destroy_array(dataArray));\r\n\r\n    } catch (af::exception& e) {\r\n        fprintf(stderr, \"%s\\n\", e.what());\r\n        throw;\r\n    }\r\n\r\n    #ifdef WIN32 // pause in Windows\r\n    if (!(argc == 2 && argv[1][0] == '-')) {\r\n        printf(\"hit [enter]...\");\r\n        fflush(stdout);\r\n        getchar();\r\n    }\r\n    #endif\r\n    return 0;\r\n}\r\n```\r\n\r\nOutput:\r\n\r\n```\r\nArrayFire v3.0.beta (CPU, 64-bit Mac OSX, build f857ac3)\r\ndataArray [4 25 1 1]\r\n   Offsets: [0 0 0 0]\r\n   Strides: [1 4 100 100]\r\n        10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10\r\n        10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10\r\n        10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10\r\n        10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10         10\r\n\r\nhelloworld_cpu(67517,0x7fff71807310) malloc: *** error for object 0x7f906a4151f0: pointer being freed was not allocated\r\n*** set a breakpoint in malloc_error_break to debug\r\n[1]    67517 abort      ./examples/helloworld/helloworld_cpu\r\n```"}}