Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-111569: Fix critical sections test on WebAssembly#111897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from1 commit
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -470,6 +470,13 @@ extern "C" { | ||||||||||||||||
| # define WITH_THREAD | ||||||||||||||||
| #endif | ||||||||||||||||
| /* Some WebAssembly platforms do not provide a working pthread implementation. | ||||||||||||||||
| * Thread support is stubbed and any attempt to create a new thread fails. | ||||||||||||||||
| */ | ||||||||||||||||
| #if !defined(__wasi__) && (!defined(__EMSCRIPTEN__) || defined(__EMSCRIPTEN_PTHREADS__)) | ||||||||||||||||
| # define Py_CAN_START_THREADS 1 | ||||||||||||||||
| #endif | ||||||||||||||||
| ||||||||||||||||
| AS_VAR_IF([enable_wasm_pthreads],[yes],[ | |
| AS_VAR_APPEND([CFLAGS_NODIST],[" -pthread"]) | |
| AS_VAR_APPEND([LDFLAGS_NODIST],[" -sUSE_PTHREADS"]) | |
| AS_VAR_APPEND([LINKFORSHARED],[" -sPROXY_TO_PTHREAD"]) | |
| ]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
@brettcannon, do you think the general approach here is a reasonable? Previously, I had been just checking for thread support on the Python side, but that's a bit awkward for these C API tests.
I'm a bit confused by your comment that you can do aWASI build with threading support. I see that there is Emscripten support for pthreads. That's already handled by the__EMSCRIPTEN_PTHREADS__ check on line 476.
The Python equivalent assumes thatWASI never supports threads:
cpython/Lib/test/support/threading_helper.py
Lines 232 to 233 in6f09f69
| elifsys.platform=="wasi": | |
| returnFalse |
I see that there is a WASI proposal for threads (https://github.com/WebAssembly/wasi-threads), but that looks like it's still marked "phase 1".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The Python equivalent assumes thatWASI never supports threads
The threading support isn't well-tested because I haven't set up a buildbot yet and made it priority to more thoroughly test it. 😅
I see that there is a WASI proposal for threads (https://github.com/WebAssembly/wasi-threads), but that looks like it's still marked "phase 1".
Yep, and it's staying at that phase because threading is being taken up by the WebAssembly CG at the W3C which acts as an upstream to WASI. That proposal hit I think phase 4 last month (it's definitely moving forward regardless of whether I got the number right), hence why this whole "threads in WASI" thing continues to be experimental both in WASI and for us.
I think we need to make a decision about free-threading and WASI. Do we want to try and make it work with the experimental threading support that's there, or do we say it's not worth it and wait on the more official support to land?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I think we need to make a decision about free-threading and WASI.
My 2¢ is "no, not for now", but I also think that's only tangentially related to this issue. The test breakage is not happening in a free-threaded (--disable-gil) build. Even if we don't support the combination of--disable-gil and wasm, I'd still like a way to determine at compile time (in C code) ifPyThread_start_new_thread will actually launch a thread (or is just a no-op stub).
I think we might be able to just useHAVE_PTHREAD_STUBS here instead of defining a newPy_CAN_START_THREADS.
I'm hoping to run this on the wasm buildbots, but I think the runner is backed up... probably because thetest_critical_sections_threads test hangs until the test suite times out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
👍 if theHAVE_PTHREADS_STUBS solution works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
And I think the buildbots have calmed down:https://buildbot.python.org/all/#/builders?tags=wasm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hmmm...HAVE_PTHREAD_STUBS did not seem to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
It appears that when built without thread support WASI usesHAVE_PTHREAD_STUBS, but Emscripten stubs pthreads internally.