{"action":"opened","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/17059","repository_url":"https://api.github.com/repos/JuliaLang/julia","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/17059/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/17059/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/17059/events","html_url":"https://github.com/JuliaLang/julia/issues/17059","id":161614094,"number":17059,"title":"Nondetermantistic codegen segfault with @threads","user":{"login":"oxinabox","id":5127634,"avatar_url":"https://avatars.githubusercontent.com/u/5127634?v=3","gravatar_id":"","url":"https://api.github.com/users/oxinabox","html_url":"https://github.com/oxinabox","followers_url":"https://api.github.com/users/oxinabox/followers","following_url":"https://api.github.com/users/oxinabox/following{/other_user}","gists_url":"https://api.github.com/users/oxinabox/gists{/gist_id}","starred_url":"https://api.github.com/users/oxinabox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oxinabox/subscriptions","organizations_url":"https://api.github.com/users/oxinabox/orgs","repos_url":"https://api.github.com/users/oxinabox/repos","events_url":"https://api.github.com/users/oxinabox/events{/privacy}","received_events_url":"https://api.github.com/users/oxinabox/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-06-22T07:44:36Z","updated_at":"2016-06-22T07:44:36Z","closed_at":null,"body":"'ve been trying to narrow this down to a smaller more deterministic MWE for a few hours.\r\nBut I can't seem to.\r\nThe code that generates the segfault seems to require the following  features, but it is hard to tell as it is a nondetermantistic fault\r\n\r\n 1. To be working with an array of arrays\r\n 2. To apply a complexish function to the data in one and store it in the other\r\n\r\nI'm not certain that 1 is not a special case of 2. as  the `@threads` can be on the inner, or the outer loop.\r\nPutting it on both seems to always fail (which is a good thing. But not, I think certain to always occur, as I had a case yesterday that started me on this quest  that didn't segfault, but just corrupted the results)\r\n\r\nIt seems like if the error is not triggered when you start running the program, it is not triggered ever.\r\n(My real code takes I think a week to run, and I left it in a loop trying to start last night, and it was running when I got in in the morning, and hasn't terminated yet.)\r\nThis makes sense since the segfault reports as occurring in codegen.cpp\r\n\r\nThe following script, for me normally generals around 2 fails and 3 successes\r\n\r\n```\r\n#!/bin/bash\r\n\r\nFAILS=0\r\nSUCCESSES=0\r\nfor i in `seq 1 5`;\r\ndo\r\n        export JULIA_NUM_THREADS=3\r\n        julia-master << HEREDOC\r\n        using Base.Threads\r\n        srand(1)\r\n\r\n        function test_f()                                          \r\n                jmax=5          \r\n                imax=20\r\n                datas = [[rand(2) for ii in 1:imax] for jj in 1:jmax]\r\n                res = [Vector{Float64}(imax) for jj in 1:jmax]\r\n                tic()\r\n                @threads for jj in 1:jmax\r\n                        for ii in 1:imax #Can put this line in a @threads instead of the above\r\n                                data = datas[jj][ii]\r\n                                res[jj][ii] = (data\\rand(2))[1] #Any complexish function call works here        \r\n                        end\r\n                end\r\n                toc()\r\n        end\r\n\r\n        test_f()\r\nHEREDOC\r\n\r\n        if [ $? -eq 0 ]\r\n        then\r\n                SUCCESSES=$((SUCCESSES+1))\r\n        else\r\n                FAILS=$((FAILS+1))\r\n        fi\r\ndone\r\n\r\necho \"$SUCCESSES successes; $FAILS fails\"\r\n\r\n```\r\n\r\n\r\nFor reference: \r\n\r\n```\r\njulia> versioninfo()\r\nJulia Version 0.5.0-dev+4805\r\nCommit 3f4e1e7 (2016-06-16 01:29 UTC)\r\nPlatform Info:\r\n  System: Linux (x86_64-linux-gnu)\r\n  CPU: AMD Opteron 63xx class CPU\r\n  WORD_SIZE: 64\r\n  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Piledriver)\r\n  LAPACK: libopenblas64_\r\n  LIBM: libopenlibm\r\n  LLVM: libLLVM-3.7.1 (ORCJIT, bdver2)\r\n```\r\n\r\n------\r\n\r\nThe precise error is\r\n\r\n```\r\nsignal (11): Segmentation fault\r\nwhile loading no file, in expression starting on line 0\r\nemit_function at /home/ubuntu/build/julia-master/src/codegen.cpp:4008\r\nto_function at /home/ubuntu/build/julia-master/src/codegen.cpp:824\r\njl_compile_linfo at /home/ubuntu/build/julia-master/src/codegen.cpp:1046\r\njl_call_method_internal at /home/ubuntu/build/julia-master/src/julia_internal.h:83\r\nmapfoldl at ./reduce.jl:64\r\nA_ldiv_B! at ./linalg/qr.jl:489\r\nA_ldiv_B!; at ./linalg/qr.jl:488\r\n\\ at ./linalg/generic.jl:347\r\nmacro expansion; at ./none:13\r\nunknown function (ip: 0x7f99a5e1b49f)\r\njl_call_method_internal at /home/ubuntu/build/julia-master/src/julia_internal.h:85\r\njl_apply at /home/ubuntu/build/julia-master/src/julia.h:1386\r\nti_threadfun at /home/ubuntu/build/julia-master/src/threading.c:240\r\nuv__thread_start at /home/ubuntu/build/julia-master/deps/srccache/libuv-a1d9166a440e4a0664c0e6de6ebe25350de56a42/src/unix/thread.c:52\r\nunknown function (ip: 0x7f9bae0d0183)\r\nunknown function (ip: 0x7f9baddfa37c)\r\nAllocations: 1706015 (Pool: 1705241; Big: 774); GC: 2\r\n```\r\n"}}
{"actor":{"display_login":"oxinabox"}}