{"action":"opened","issue":{"url":"https://api.github.com/repos/arrayfire/arrayfire/issues/1126","labels_url":"https://api.github.com/repos/arrayfire/arrayfire/issues/1126/labels{/name}","comments_url":"https://api.github.com/repos/arrayfire/arrayfire/issues/1126/comments","events_url":"https://api.github.com/repos/arrayfire/arrayfire/issues/1126/events","html_url":"https://github.com/arrayfire/arrayfire/issues/1126","id":119085693,"number":1126,"title":"Crash when using af::replace or af::select","user":{"login":"rggjan","id":128554,"avatar_url":"https://avatars.githubusercontent.com/u/128554?v=3","gravatar_id":"","url":"https://api.github.com/users/rggjan","html_url":"https://github.com/rggjan","followers_url":"https://api.github.com/users/rggjan/followers","following_url":"https://api.github.com/users/rggjan/following{/other_user}","gists_url":"https://api.github.com/users/rggjan/gists{/gist_id}","starred_url":"https://api.github.com/users/rggjan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rggjan/subscriptions","organizations_url":"https://api.github.com/users/rggjan/orgs","repos_url":"https://api.github.com/users/rggjan/repos","events_url":"https://api.github.com/users/rggjan/events{/privacy}","received_events_url":"https://api.github.com/users/rggjan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-26T17:46:03Z","updated_at":"2015-11-26T17:46:03Z","closed_at":null,"body":"When I execute the following code (which should be completely independent and have no side effects):\r\n\r\n```\r\n{\r\n    int w = 100;\r\n    int h = 100;\r\n    int dim = 2; // Using dim=1 works fine!\r\n\r\n    af::array diffs = af::constant(0, w, h, dim, s32);\r\n    af::array vals = af::constant(128, w, h, dim, u8);\r\n    af::array condition = vals==128;\r\n\r\n    int version = 1;\r\n\r\n    if (version == 1) // This makes it crash\r\n      af::replace(diffs, condition, af::constant(0, w, h, dim, s32));\r\n\r\n    if (version == 2) // This makes it crash\r\n      diffs = af::select(condition, diffs, af::constant(0, w, h, dim, s32));\r\n\r\n    if (version == 3) // This works fine!\r\n      diffs = condition*diffs + (!condition)*af::constant(0, w, h, dim, s32);\r\n  }\r\n```\r\n\r\nMy program starts to crash (after some time) in a completely unrelated function, when I'm creating a new array (I'm sorry I cannot pin it down further):\r\n\r\n```\r\naf::array tmp(w, h, data_ptr);\r\n```\r\n\r\nIts a really bad crash: I get an arrayfire exception and a message from the NVidia driver, that it stopped and recovered. \r\n\r\nThe arrayfire exception is:\r\n```\r\nException: ArrayFire Exception(998): Internal error\r\nIn C:\\workspace\\af_inst_source\\src\\api\\cpp\\array.cpp:139\r\n```\r\nand an image of some sort of stacktrace is attached.\r\n\r\n![stacktrace](https://cloud.githubusercontent.com/assets/128554/11428618/9adfb37a-946d-11e5-9e7d-2907038f4ef9.PNG)\r\n\r\nI think it must be a bug, because without these lines, my code runs perfectly fine. Even when using a \"custom built\" implementation (version 3) of replace, it works fine. Also, using only one dimension instead of two works fine. So I guess some global state or something that must break when using version 1 or 2. \r\n\r\nI'm using arrayfire 3.2.0 on Windows 10 64-bit. "}}