diff --git a/src/library_pthread.js b/src/library_pthread.js index 680a6ac9dd316..dda54a72c37e0 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -716,8 +716,10 @@ var LibraryPThread = { transferredCanvasNames = '{{{ OFFSCREENCANVASES_TO_PTHREAD }}}'; } else #endif - transferredCanvasNames &&= UTF8ToString(transferredCanvasNames).trim(); - transferredCanvasNames &&= transferredCanvasNames.split(','); + { + transferredCanvasNames = UTF8ToString(transferredCanvasNames).trim(); + } + transferredCanvasNames = transferredCanvasNames ? transferredCanvasNames.split(',') : []; #if GL_DEBUG dbg(`pthread_create: transferredCanvasNames="${transferredCanvasNames}"`); #endif diff --git a/test/other/test_pthread_hello.c b/test/other/test_pthread_hello.c new file mode 100644 index 0000000000000..e73139f2be528 --- /dev/null +++ b/test/other/test_pthread_hello.c @@ -0,0 +1,17 @@ +#include +#include +#include + +void* thread_func(void* arg) { + printf("Hello from thread\n"); + return NULL; +} + +int main() { + pthread_t t; + pthread_create(&t, NULL, thread_func, NULL); + assert(t); + pthread_join(t, NULL); + printf("done\n"); + return 0; +} diff --git a/test/other/test_pthread_hello.out b/test/other/test_pthread_hello.out new file mode 100644 index 0000000000000..d27926954cf1e --- /dev/null +++ b/test/other/test_pthread_hello.out @@ -0,0 +1,2 @@ +Hello from thread +done diff --git a/test/test_other.py b/test/test_other.py index 04c3dbc89bc93..2cfaf41a08288 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -12080,6 +12080,14 @@ def test_pthread_reuse(self): self.set_setting('PTHREAD_POOL_SIZE', 1) self.do_other_test('test_pthread_reuse.c') + @parameterized({ + '': ([],), + 'offscreen_canvas': (['-sOFFSCREENCANVAS_SUPPORT', '-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=$GL'],), + }) + @node_pthreads + def test_pthread_hello(self, args): + self.do_other_test('test_pthread_hello.c', args) + @node_pthreads def test_pthread_relocatable(self): self.do_run_in_out_file_test('hello_world.c', emcc_args=['-sRELOCATABLE'])