Pthreads: Fix proxying confusion between main browser and main runtime thread (#12102)

The main browser thread is the page with the DOM and HTML, while the
main runtime thread is where we start up the JS, and where things like
stdio proxying go (so all file access is on the same thread). Normally that
is the same place. However, a pthreads application started in a worker has
no access to the main browser thread. In that case emscripten_is_main_browser_thread
always returns false, while emscripten_is_main_runtime_thread returns
true (on the main thread).

This PR fixes some confusion there, some proxying code checked the
main browser thread when it meant to check the main runtime thread.
In that case we actually care about handling proxied calls. Without this fix,
the testcase added here just hangs, as we never handle proxied calls
to the main runtime thread (since we think we are never that thread).

Fixes #11914 (testcase in #12080)
2 files changed
tree: cf9277587d95994656d7b7cb88d648a423915d7d
  1. .circleci/
  2. .github/
  3. cmake/
  4. docs/
  5. media/
  6. site/
  7. src/
  8. system/
  9. tests/
  10. third_party/
  11. tools/
  12. .clang-format
  13. .editorconfig
  14. .flake8
  15. .gitattributes
  16. .gitignore
  17. .style.yapf
  18. AUTHORS
  19. ChangeLog.md
  20. CONTRIBUTING.md
  21. em++
  22. em++.bat
  23. em++.py
  24. em-config
  25. em-config.bat
  26. em-config.py
  27. emar
  28. emar.bat
  29. emar.py
  30. embuilder
  31. embuilder.bat
  32. embuilder.py
  33. emcc
  34. emcc.bat
  35. emcc.py
  36. emcmake
  37. emcmake.bat
  38. emcmake.py
  39. emconfigure
  40. emconfigure.bat
  41. emconfigure.py
  42. emlink.py
  43. emmake
  44. emmake.bat
  45. emmake.py
  46. emranlib
  47. emranlib.bat
  48. emranlib.py
  49. emrun
  50. emrun.bat
  51. emrun.py
  52. emscons
  53. emscons.bat
  54. emscons.py
  55. emscripten-version.txt
  56. emscripten.py
  57. emsize
  58. emsize.bat
  59. emsize.py
  60. LICENSE
  61. Makefile
  62. package-lock.json
  63. package.json
  64. README.md
README.md

emscripten logo

CircleCI

Main project page: http://emscripten.org

Overview

Emscripten compiles C and C++ to WebAssembly using LLVM and Binaryen. Emscripten output can run on the Web, in Node.js, and in wasm runtimes.

Emscripten provides Web support for popular portable APIs such as OpenGL and SDL2, allowing complex graphical native applications to be ported, such as the Unity game engine and Google Earth. It can probably port your codebase, too!

While Emscripten mostly focuses on compiling C and C++ using Clang, it can be integrated with other LLVM-using compilers (for example, Rust has Emscripten integration, with the wasm32-unknown-emscripten and asmjs-unknown-emscripten targets).

License

Emscripten is available under 2 licenses, the MIT license and the University of Illinois/NCSA Open Source License.

Both are permissive open source licenses, with little if any practical difference between them.

The reason for offering both is that (1) the MIT license is well-known, while (2) the University of Illinois/NCSA Open Source License allows Emscripten's code to be integrated upstream into LLVM, which uses that license, should the opportunity arise.

See LICENSE for the full content of the licenses.