{"action":"opened","issue":{"url":"https://api.github.com/repos/kripken/emscripten/issues/3636","labels_url":"https://api.github.com/repos/kripken/emscripten/issues/3636/labels{/name}","comments_url":"https://api.github.com/repos/kripken/emscripten/issues/3636/comments","events_url":"https://api.github.com/repos/kripken/emscripten/issues/3636/events","html_url":"https://github.com/kripken/emscripten/issues/3636","id":96649357,"number":3636,"title":"USE_PTHREADS freezes Firefox Nightly 42.0a1","user":{"login":"Kagami","id":533383,"avatar_url":"https://avatars.githubusercontent.com/u/533383?v=3","gravatar_id":"","url":"https://api.github.com/users/Kagami","html_url":"https://github.com/Kagami","followers_url":"https://api.github.com/users/Kagami/followers","following_url":"https://api.github.com/users/Kagami/following{/other_user}","gists_url":"https://api.github.com/users/Kagami/gists{/gist_id}","starred_url":"https://api.github.com/users/Kagami/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Kagami/subscriptions","organizations_url":"https://api.github.com/users/Kagami/orgs","repos_url":"https://api.github.com/users/Kagami/repos","events_url":"https://api.github.com/users/Kagami/events{/privacy}","received_events_url":"https://api.github.com/users/Kagami/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-07-22T19:47:45Z","updated_at":"2015-07-22T19:47:45Z","closed_at":null,"body":"Hi. I'm trying to make simple threads example to work with Emscripten's `-s USE_PTHREADS=1` option but unfortunately it doesn't work with latest stable Emscripten and Firefox Nightly. Probably I'm doing something stupidly wrong, sorry for that.\r\n\r\nHere is simple pthread example:\r\n\r\n```c\r\n$ cat 1.c \r\n#include <stdio.h>\r\n#include <pthread.h>\r\n\r\nvoid *thread_fn(void *arg) {\r\n    printf(\"Thread done\\n\");\r\n    return NULL;\r\n}\r\n\r\nint main(void)\r\n{\r\n    pthread_t thread1, thread2;\r\n    pthread_create(&thread1, NULL, thread_fn, NULL);\r\n    pthread_create(&thread2, NULL, thread_fn, NULL);\r\n    pthread_join(thread1, NULL);\r\n    pthread_join(thread2, NULL);\r\n    printf(\"Done\\n\");\r\n    return 0;\r\n}\r\n```\r\n\r\nI'm compiling it with the following options to `index.html`:\r\n\r\n```\r\n$ emcc -s USE_PTHREADS=1 1.c -o index.html\r\nwarning: unresolved symbol: posix_spawn\r\nwarning: unresolved symbol: posix_spawn_file_actions_adddup2\r\nwarning: unresolved symbol: posix_spawn_file_actions_init\r\nwarning: unresolved symbol: posix_spawn_file_actions_destroy\r\n```\r\n\r\nWhen I open the resulting page in Firefox, it freezes the window. If I stop the script, I got the following text at page's console:\r\n\r\n```\r\nPreallocating 1 workers for a pthread spawn pool.\r\nPreallocating 1 workers for a pthread spawn pool.\r\nThread done\r\nThread done\r\n```\r\n\r\nand this in the browser's console:\r\n\r\n```\r\npre-main prep time: 6 ms t:1245:13\r\n\r\nPreallocating 1 workers for a pthread spawn pool. t:1233:13\r\nError: Script terminated by timeout at:\r\n_emscripten_futex_wait@http://127.0.0.1:4444/t/index.js:5479:17\r\n_pthread_join@http://127.0.0.1:4444/t/index.js:6862:9\r\n_main@http://127.0.0.1:4444/t/index.js:8698:3\r\nasm._main@http://127.0.0.1:4444/t/index.js:34880:8\r\ncallMain@http://127.0.0.1:4444/t/index.js:35041:15\r\ndoRun@http://127.0.0.1:4444/t/index.js:35100:42\r\nrun/<@http://127.0.0.1:4444/t/index.js:35111:7\r\n index.js:5479:17\r\nThread done\r\n```\r\n\r\nIf I compile the code with pool size option:\r\n\r\n```\r\nemcc -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=2 1.c -o index.html\r\n```\r\n\r\nI got the following error at the page instead:\r\n\r\n```\r\nPreallocating 2 workers for a pthread spawn pool.\r\nAssertion failed: you need to wait for the runtime to be ready (e.g. wait for main() to be called)\r\n```\r\n\r\nI tried to compile `test_pthread_join.cpp` from the Emscripten's test suite but got the same result.\r\n\r\n```\r\nemcc -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=-1 -s PTHREAD_HINT_NUM_CORES=-1 1.c -o index.html\r\n```\r\n\r\ngives me Thread setup popup on page load but after that I got errors in console and can't see the threads output:\r\n\r\n```\r\nReferenceError: _emscripten_force_num_logical_cores is not defined index.js:1631:5\r\nstill waiting on run dependencies: t:1245:13\r\ndependency: pthreads_querycores t:1245:13\r\n(end of list) t:1245:13\r\nstill waiting on run dependencies: t:1245:13\r\ndependency: pthreads_querycores t:1245:13\r\n(end of list) t:1245:13\r\nstill waiting on run dependencies: t:1245:13\r\ndependency: pthreads_querycores t:1245:13\r\n(end of list) t:1245:13\r\n```\r\n\r\nAm I doing something wrong? I'm using `emscripten/tag-1.34.3` and `Firefox 42.0a1 (2015-07-22)`."}}