{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/numexpr/issues/80","labels_url":"https://api.github.com/repos/pydata/numexpr/issues/80/labels{/name}","comments_url":"https://api.github.com/repos/pydata/numexpr/issues/80/comments","events_url":"https://api.github.com/repos/pydata/numexpr/issues/80/events","html_url":"https://github.com/pydata/numexpr/issues/80","id":26080147,"number":80,"title":"numexpr is not thread-safe","user":{"login":"FrancescAlted","id":314521,"avatar_url":"https://avatars.githubusercontent.com/u/314521?v=3","gravatar_id":"","url":"https://api.github.com/users/FrancescAlted","html_url":"https://github.com/FrancescAlted","followers_url":"https://api.github.com/users/FrancescAlted/followers","following_url":"https://api.github.com/users/FrancescAlted/following{/other_user}","gists_url":"https://api.github.com/users/FrancescAlted/gists{/gist_id}","starred_url":"https://api.github.com/users/FrancescAlted/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FrancescAlted/subscriptions","organizations_url":"https://api.github.com/users/FrancescAlted/orgs","repos_url":"https://api.github.com/users/FrancescAlted/repos","events_url":"https://api.github.com/users/FrancescAlted/events{/privacy}","received_events_url":"https://api.github.com/users/FrancescAlted/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/pydata/numexpr/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/pydata/numexpr/labels/imported","name":"imported","color":"FFFFFF"},{"url":"https://api.github.com/repos/pydata/numexpr/labels/Priority-Medium","name":"Priority-Medium","color":"FFFFFF"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2014-01-22T10:37:03Z","updated_at":"2016-01-21T14:36:02Z","closed_at":null,"body":"_From [vovan...@gmail.com](https://code.google.com/u/110660466581669505267/) on April 30, 2012 23:46:07_\n\nCalling numexpr.evaluate from two different threads at the same time causes a segfault, unless numexpr.set_num_threads(1) was called prior.\r\n\r\nLooking at the code in vm_engine_iter_parallel, it looks to me like it uses a global variable to store thread information, and so chokes when two different threads call that function at the same time.\r\n\r\nSee attached file for a small code sample that reproduces this problem. And here's what I see when I actually run that script from the shell:\r\n\r\n{{{\r\n> python -c 'import numexpr; numexpr.test()'\r\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\nNumexpr version:   2.0.1\r\nNumPy version:     1.6.1\r\nPython version:    2.7.2 (default, Dec 13 2011, 14:11:54)\r\n[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)]\r\nPlatform:          linux2-x86_64\r\nAMD/Intel CPU?     True\r\nVML available?     False\r\nDetected cores:    24\r\n-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\r\n[... snip ...]\r\n----------------------------------------------------------------------\r\nRan 5103 tests in 3.805s\r\n\r\nOK\r\n\r\n> python numexprCore.py\r\nStarting threads\r\nWaiting\r\nSegmentation fault (core dumped)\r\n}}}\n\n**Attachment:** [numexprCore.py](http://code.google.com/p/numexpr/issues/detail?id=80)\n\n_Original issue: http://code.google.com/p/numexpr/issues/detail?id=80_"},"comment":{"url":"https://api.github.com/repos/pydata/numexpr/issues/comments/173586640","html_url":"https://github.com/pydata/numexpr/issues/80#issuecomment-173586640","issue_url":"https://api.github.com/repos/pydata/numexpr/issues/80","id":173586640,"user":{"login":"jennolsen84","id":10360673,"avatar_url":"https://avatars.githubusercontent.com/u/10360673?v=3","gravatar_id":"","url":"https://api.github.com/users/jennolsen84","html_url":"https://github.com/jennolsen84","followers_url":"https://api.github.com/users/jennolsen84/followers","following_url":"https://api.github.com/users/jennolsen84/following{/other_user}","gists_url":"https://api.github.com/users/jennolsen84/gists{/gist_id}","starred_url":"https://api.github.com/users/jennolsen84/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jennolsen84/subscriptions","organizations_url":"https://api.github.com/users/jennolsen84/orgs","repos_url":"https://api.github.com/users/jennolsen84/repos","events_url":"https://api.github.com/users/jennolsen84/events{/privacy}","received_events_url":"https://api.github.com/users/jennolsen84/received_events","type":"User","site_admin":false},"created_at":"2016-01-21T14:36:02Z","updated_at":"2016-01-21T14:36:02Z","body":"That's what I did in the PR, and it seems to have fixed the crash"}}