Skip to content

Commit 81aba2d

Browse files
committed
Avoid proxying print handlers back to the main thread
This partially reverts commit 97b352e. Resolves: #19683.
1 parent a4d0dbc commit 81aba2d

File tree

3 files changed

+1
-46
lines changed

3 files changed

+1
-46
lines changed

src/lib/libpthread.js

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,12 +344,6 @@ var LibraryPThread = {
344344
#endif
345345
#if expectToReceiveOnModule('onAbort')
346346
'onAbort',
347-
#endif
348-
#if expectToReceiveOnModule('print')
349-
'print',
350-
#endif
351-
#if expectToReceiveOnModule('printErr')
352-
'printErr',
353347
#endif
354348
];
355349
for (var handler of knownHandlers) {

src/runtime_pthread.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ if (ENVIRONMENT_IS_PTHREAD) {
8282
// Use `const` here to ensure that the variable is scoped only to
8383
// that iteration, allowing safe reference from a closure.
8484
for (const handler of msgData.handlers) {
85-
// The the main module has a handler for a certain even, but no
85+
// The main module has a handler for a certain event, but no
8686
// handler exists on the pthread worker, then proxy that handler
8787
// back to the main thread.
8888
if (!Module[handler] || Module[handler].proxy) {
@@ -95,9 +95,6 @@ if (ENVIRONMENT_IS_PTHREAD) {
9595
#endif
9696
postMessage({ cmd: 'callHandler', handler, args: args });
9797
}
98-
// Rebind the out / err handlers if needed
99-
if (handler == 'print') out = Module[handler];
100-
if (handler == 'printErr') err = Module[handler];
10198
}
10299
#if RUNTIME_DEBUG
103100
else dbg(`worker: using thread-local handler: ${handler}`);

test/test_other.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7235,42 +7235,6 @@ def test_modularize_instantiation_error(self):
72357235
self.assertContained('failed to asynchronously prepare wasm', output)
72367236
self.assertContained('got error: RuntimeError: Aborted', output)
72377237

7238-
@crossplatform
7239-
@node_pthreads
7240-
@flaky('https://github.com/emscripten-core/emscripten/issues/19683')
7241-
# The flakiness of this test is very high on macOS so just disable it
7242-
# completely.
7243-
@no_mac('https://github.com/emscripten-core/emscripten/issues/19683')
7244-
def test_pthread_print_override_modularize(self):
7245-
self.set_setting('EXPORT_NAME', 'Test')
7246-
self.set_setting('PROXY_TO_PTHREAD')
7247-
self.set_setting('EXIT_RUNTIME')
7248-
self.set_setting('MODULARIZE')
7249-
create_file('main.c', '''
7250-
#include <emscripten/console.h>
7251-
7252-
int main() {
7253-
emscripten_out("hello, world!");
7254-
return 0;
7255-
}
7256-
''')
7257-
create_file('main.js', '''
7258-
const Test = require('./test.js');
7259-
7260-
async function main() {
7261-
await Test({
7262-
// world -> earth
7263-
print: (text) => console.log(text.replace('world', 'earth'))
7264-
});
7265-
}
7266-
main();
7267-
''')
7268-
7269-
self.emcc('main.c', output_filename='test.js')
7270-
output = self.run_js('main.js')
7271-
self.assertNotContained('hello, world!', output)
7272-
self.assertContained('hello, earth!', output)
7273-
72747238
def test_define_modularize(self):
72757239
self.run_process([EMCC, test_file('hello_world.c'), '-sMODULARIZE', '-sASSERTIONS=0'])
72767240
src = 'var module = 0; ' + read_file('a.out.js')

0 commit comments

Comments
 (0)