You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I maintain a custom implementation of a WASI Host (https://github.com/microsoft/vscode-wasm) on top of the VS Code API. This enables running wasm-wasi binaries and provide them transparent access to the VS Code file system, the console or a terminal.
I was very excited when I saw that there is a pre-release for thread support and started to add thread support to VS Code's host implementation. I implemented the necessary wasi::thread-spawn import however starting the thread fails with a runtime exception that looks like:
RuntimeError: null function or function signature mismatch
at __wasi_thread_start_C (0002bda6:0x67db)
at wasi_thread_start (0002bda6:0x7301)
at port.onmessage (threadWorker.js:1921:28)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> //Header file for sleep(). man 3 sleep for details.
#include <pthread.h>
// A normal C function that is executed as a thread
// when its name is specified in pthread_create()
void *myThreadFun(void *vargp)
{
sleep(1);
printf("Printing GeeksQuiz from Thread \n");
return NULL;
}
int main()
{
pthread_t thread_id;
printf("Before Thread\n");
int result = pthread_create(&thread_id, NULL, myThreadFun, NULL);
printf("Thread created with result: %i\n", result);
result = pthread_join(thread_id, NULL);
printf("Thread joined with result: %i\n", result);
printf("After Thread\n");
exit(0);
}
I compile the program to WASM using the following command:
Was the problem related to signature of the myThreadFun entry point?
In emscripten we had an issue where some code was using the wrong signature for the thread entry point (e.g. not taking any arguments at all). In C apparently this is OK but when compiled down to wasm things break.
I maintain a custom implementation of a WASI Host (https://github.com/microsoft/vscode-wasm) on top of the VS Code API. This enables running wasm-wasi binaries and provide them transparent access to the VS Code file system, the console or a terminal.
I was very excited when I saw that there is a pre-release for thread support and started to add thread support to VS Code's host implementation. I implemented the necessary
wasi::thread-spawn
import however starting the thread fails with a runtime exception that looks like:The C program I compile looks like this (slightly modified version from (https://www.geeksforgeeks.org/multithreading-in-c/):
I compile the program to WASM using the following command:
The exception happens on this WASI statement
A more detailed view in the debugger is:
Any idea what I do wrong?
From debugging it I am pretty sure that the
tid
and thestart_arg
pointer are correct.The text was updated successfully, but these errors were encountered: