In the actual implementation of malloc the system queue may be executed non-deterministically if malloc is waiting on a mutex. This wraps malloc and executes the system queue during every allocation to make the behavior deterministic.
| 16 | // executes the system queue during every allocation to make the behavior |
| 17 | // deterministic. |
| 18 | void *malloc(size_t size) { |
| 19 | if (emscripten_is_main_runtime_thread()) { |
| 20 | emscripten_proxy_execute_queue(emscripten_proxy_get_system_queue()); |
| 21 | } |
| 22 | void *ptr = emscripten_builtin_malloc(size); |
| 23 | return ptr; |
| 24 | } |
| 25 | |
| 26 | void task(void* arg) { |
| 27 | emscripten_out("task\n"); |
no test coverage detected