shunwang / numexpr

Automatically exported from code.google.com/p/numexpr
MIT License
0 stars 0 forks source link

numexpr is not thread-safe #80

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Calling numexpr.evaluate from two different threads at the same time causes a 
segfault, unless numexpr.set_num_threads(1) was called prior.

Looking 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.

See 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:

{{{
> python -c 'import numexpr; numexpr.test()'
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Numexpr version:   2.0.1
NumPy version:     1.6.1
Python version:    2.7.2 (default, Dec 13 2011, 14:11:54)
[GCC 4.1.2 20080704 (Red Hat 4.1.2-50)]
Platform:          linux2-x86_64
AMD/Intel CPU?     True
VML available?     False
Detected cores:    24
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[... snip ...]
----------------------------------------------------------------------
Ran 5103 tests in 3.805s

OK

> python numexprCore.py
Starting threads
Waiting
Segmentation fault (core dumped)
}}}

Original issue reported on code.google.com by vovan...@gmail.com on 30 Apr 2012 at 9:46

Attachments: