{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/18794","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/18794/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/18794/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/18794/events","html_url":"https://github.com/JuliaLang/julia/issues/18794","id":181060048,"number":18794,"title":"Possible compilation bug - execution and `@code_native` sometimes don't terminate when rebinding variables","user":{"login":"andyferris","id":2974526,"avatar_url":"https://avatars.githubusercontent.com/u/2974526?v=3","gravatar_id":"","url":"https://api.github.com/users/andyferris","html_url":"https://github.com/andyferris","followers_url":"https://api.github.com/users/andyferris/followers","following_url":"https://api.github.com/users/andyferris/following{/other_user}","gists_url":"https://api.github.com/users/andyferris/gists{/gist_id}","starred_url":"https://api.github.com/users/andyferris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andyferris/subscriptions","organizations_url":"https://api.github.com/users/andyferris/orgs","repos_url":"https://api.github.com/users/andyferris/repos","events_url":"https://api.github.com/users/andyferris/events{/privacy}","received_events_url":"https://api.github.com/users/andyferris/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-05T03:59:30Z","updated_at":"2016-10-06T05:26:57Z","closed_at":null,"body":"I have made a few small changes to *StaticArrays.jl* and found that my tests fail to terminate in certain circumstances. I've managed to make a smallish repro:\r\n\r\n```julia\r\nPkg.add(\"StaticArrays\")\r\nPkg.checkout(\"StaticArrays\",\"fast_array_convert\")\r\nusing StaticArrays\r\nfunction f()\r\n    m_array = rand(1:10, 10, 10)\r\n    n_array = rand(1:10, 10, 10)\r\n    a_array = m_array*n_array\r\n\r\n    m = SMatrix{10,10}(m_array)\r\n    n = SMatrix{10,10}(n_array)\r\n    out1 = (m*n === SMatrix{10,10}(a_array))\r\n\r\n    m_array = rand(1:10, 16, 16)\r\n    n_array = rand(1:10, 16, 16)\r\n    a_array = m_array*n_array\r\n\r\n    m = SMatrix{16,16}(m_array)\r\n    n = SMatrix{16,16}(n_array)\r\n    out2 = ( m*n === SMatrix{16,16}(a_array) )\r\n    out1, out2\r\nend\r\nf() # doesn't terminate - need to press ctrl-c 5 times\r\n```\r\n\r\nHowever this function is fine, where I use unique variable names:\r\n```\r\njulia> function f()\r\n           m_array = rand(1:10, 10, 10)\r\n           n_array = rand(1:10, 10, 10)\r\n           a_array = m_array*n_array\r\n\r\n           m = SMatrix{10,10}(m_array)\r\n           n = SMatrix{10,10}(n_array)\r\n           out1 = (m*n === SMatrix{10,10}(a_array))\r\n\r\n           m_array2 = rand(1:10, 16, 16)\r\n           n_array2 = rand(1:10, 16, 16)\r\n           a_array2 = m_array2*n_array2\r\n\r\n           m2 = SMatrix{16,16}(m_array2)\r\n           n2 = SMatrix{16,16}(n_array2)\r\n           out2 = ( m2*n2 === SMatrix{16,16}(a_array2) )\r\n           out1, out2\r\n       end\r\nf (generic function with 1 method)\r\n\r\njulia> f()\r\n(true,true)\r\n```\r\n\r\nSo avoiding rebinding the variables seems to fix the problem. I'm not sure what part of the process is going wrong. I can generate up to `@code_llvm` but `@code_native` is not terminating either. \r\n\r\nTo give some hints: this seems really fragile to relatively small changes to `StaticArrays`. I came across this when I changed some code for the conversion from `Array` to static arrays (the lines starting with `m = ...` and `n = ...`). However the freezing specifically occurs when I include both the multiplication operations `m*n` (which result in a large amount of inlined code to be added to the function).\r\n\r\nEDIT - I've reproduced this on Linux and Windows on v0.5.0, but somehow travis didn't have this problem (tests completed in 40 seconds which is typical for this package)."},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/251870227","html_url":"https://github.com/JuliaLang/julia/issues/18794#issuecomment-251870227","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/18794","id":251870227,"user":{"login":"vtjnash","id":330950,"avatar_url":"https://avatars.githubusercontent.com/u/330950?v=3","gravatar_id":"","url":"https://api.github.com/users/vtjnash","html_url":"https://github.com/vtjnash","followers_url":"https://api.github.com/users/vtjnash/followers","following_url":"https://api.github.com/users/vtjnash/following{/other_user}","gists_url":"https://api.github.com/users/vtjnash/gists{/gist_id}","starred_url":"https://api.github.com/users/vtjnash/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vtjnash/subscriptions","organizations_url":"https://api.github.com/users/vtjnash/orgs","repos_url":"https://api.github.com/users/vtjnash/repos","events_url":"https://api.github.com/users/vtjnash/events{/privacy}","received_events_url":"https://api.github.com/users/vtjnash/received_events","type":"User","site_admin":false},"created_at":"2016-10-06T05:26:57Z","updated_at":"2016-10-06T05:26:57Z","body":"It looks like SMatrix is expanding to code that creates several thousand stack copies of `[256 x i64]`. In the type-stable case, the compiler is lazy and mostly elids these, but in the type-unstable case we are failing to fall back to malloc and making a copy of the gc-root instead. (well, we're also failing to call malloc in the first case, but it makes fewer copies so the performance loss from this is less obvious; and without loops there's no chance of it recognizing the blas kernel in this, or even just rerolled, so it's already giving up 1-2 orders of magnitude of performance anyways)."}}
{"actor":{"display_login":"vtjnash"}}