Comments (9)
#1346 leads to a bunch of extra compiler warnings about aligned-new
, but it resolves the issue with em++
and for g++
+ static libs
from onetbb.
Compiling with optimizations -O3
yields an even more cryptic error when run by node
:
RuntimeError: null function or function signature mismatch
at wasm://wasm/000993ba:wasm-function[115]:0x948c
at wasm://wasm/000993ba:wasm-function[50]:0x49ac
at wasm://wasm/000993ba:wasm-function[32]:0x36d7
at wasm://wasm/000993ba:wasm-function[95]:0x7e00
at callRuntimeCallbacks (/home/brian/Dev/cpp/tinystan/test.js:1:7797)
at initRuntime (/home/brian/Dev/cpp/tinystan/test.js:1:3877)
at doRun (/home/brian/Dev/cpp/tinystan/test.js:1:15378)
at run (/home/brian/Dev/cpp/tinystan/test.js:1:15657)
at runCaller (/home/brian/Dev/cpp/tinystan/test.js:1:14784)
at removeRunDependency (/home/brian/Dev/cpp/tinystan/test.js:1:4829)
Node.js v19.9.0
from onetbb.
Something is very fishy here. The static variable controls
seems to have a segfault. I did not understand why but I suspect is about the initialization order.
oneTBB/src/tbb/global_control.cpp
Line 146 in 224eca3
When this is fixed (e.g. storing its contents on the heap), the next bug is even more cryptic to me: The stack base and the thread stack size fail in the assertion below when invoking initializing a thread in init_external_thread()
:
oneTBB/src/tbb/scheduler_common.h
Line 570 in 224eca3
This is far from my understanding. But I suspect that this comes from the hardcoded values for the stack size:
Line 61 in 224eca3
and maybe a wrong assumption on the trick to get the stack base address:
Line 118 in 224eca3
This happens also when the observer is disabled. Meaning that the segfault reported here may be actually hiding a bug on the thread initialization...
from onetbb.
I believe @SoilRos is right here and there is problem with order of global objects initialization i.e., both objects control_storage
and global observer
are global.
We had similar problem in past that were triggered with allocator initialization but since we fixed there were no reports.
I'm not sure if it's WASM specific (I could not reproduce it with gcc on Ubuntu).
@WardBrian Could you work-around this issue by calling observe
in the start of the main
?
from onetbb.
@SoilRos could you please describe what example are you running to get new error?
from onetbb.
Hi @pavelkumbrasev -
The example I provided is simplified from one in the Stan Math library. It would be non-trivial to move this to main
, if only because there are multiple users of the library who would all need to do such a move. If there is no other option for wasm I could likely do some #ifdef
trickery.
from onetbb.
@pavelkumbrasev The docker file in https://github.com/josephholten/em-multi/tree/tbb-1314 (branch tbb-1341
) reproduces the fix (using #1346) and the new error stated above on. It basically runs a scalar product on a TBB parallel_for
and adds an observer to the scheduler. When built in release mode, the assert is not checked and seems to run. However, the observers are called after the parallel loop. I tried give the thread initialization more time, but it did not work. It may be related to the thread initialization problems I stated above.
TBB thread index: 0
C++ thread: 130372
filling random vectors... 67108864
calculating sequential scalarproduct...
using thread: 130372
seq scalarprod: 16775473.896405
seq time: 48ms
calculating tbb_threads scalarproduct...
using thread: 130372
tbb_threads scalarprod: 32788.941543
tbb_threads time: 57ms
TBB thread index: 1
C++ thread: 1073994376
TBB thread index: 2
C++ thread: 1076093760
TBB thread index: 3
C++ thread: 1078196232
from onetbb.
@SoilRos init_external_thread
in that simplified scenario will be called only for main thread so it should not affect workers.
It's also possible that thread creation takes more time then parallel region. You can try to set thread barrier
+ tbb::static_partitioner
to make sure that worker threads will eventually arrive into parallel region.
Regarding the main issue. I'm not sure right now if this issue related to TBB or can be reproduced with any other library if order of global objects initialization is involved. If the problem is persistent everywhere then the right thing is report it to em++
.
from onetbb.
@pavelkumbrasev I was able to reproduce with g++
when I built TBB as a static library (which em++ always does)
cmake .. -DTBB_STRICT=OFF -DTBB_DISABLE_HWLOC_AUTOMATIC_SEARCH=ON -DBUILD_SHARED_LIBS=OFF -DTBB_EXAMPLES=OFF -DTBB_TEST=OFF
cmake --build . -j10
g++ -o test test.cpp -I../include -Lgnu_11.4_cxx11_64_relwithdebinfo/ -ltbb
output:
Program received signal SIGSEGV, Segmentation fault.
tbb::detail::r1::global_control_active_value_unsafe (param=param@entry=tbb::detail::d1::global_control::max_allowed_parallelism) at /home/brian/Dev/cpp/oneTBB/src/tbb/global_control.cpp:163
163 return controls[param]->active_value_unsafe();
from onetbb.
Related Issues (20)
- Deadlock issue in OpenBLAS with TBB HOT 2
- 2021.12.0: missing tag/release? HOT 3
- doc/README.md is misleading HOT 2
- Immediately scheduling task on a different thread HOT 9
- std::aligned_storage is deprecated in C++23 HOT 1
- Security.md: replace incorrect email address
- Support priority for join_node HOT 1
- CMake FetchContent fails to install oneTBB HOT 2
- Avoid split constructor for the Range concept HOT 2
- Compiling TBB with recent GCC 13.2, 11.4 fails HOT 2
- Possible lifetime issue with parallel_scan over non trivially destructible range HOT 3
- WASM - linking to both `-ltbb` and `-ltbbmalloc` gives duplicate symbol error for `itt_notify` HOT 4
- Potential Array Out of Bounds and Redundant Code in create_record Function HOT 1
- static_partitioner + global_control triggers an unbounded memory leak HOT 2
- Can't compile concurrent_vector with include winsock2.h or ws2tcpip.h HOT 5
- OpenBSD and NetBSD doesn't have the cpuset_* feature HOT 3
- Unable to use tbb.framework in an iOS app HOT 3
- WASM + Debug HOT 5
- tbb::global_control does not stop spinning threads HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from onetbb.