Increase default native stack size (#2332)

Calling `__wasi_sock_addr_resolve` syscall causes native stack overflow.
Given this is a standard function available in WAMR, we should have at least
the default stack size large enough to handle this case.

The socket tests were updated so they also run in separate thread, but
the simple retro program is:

```C
void *th(void *p)
{
    struct addrinfo *res;
    getaddrinfo("amazon.com", NULL, NULL, &res);
    return NULL;
}

int main(int argc, char **argv)
{
    pthread_t pt;
    pthread_create(&pt, NULL, th, NULL);
    pthread_join(pt, NULL);
    return 0;
}
```
This commit is contained in:
Marcin Kolny 2023-07-03 14:02:10 +01:00 committed by GitHub
parent 569f702ec2
commit 6ed4c9c908
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 3 deletions

View File

@ -384,7 +384,7 @@
#define APP_THREAD_STACK_SIZE_DEFAULT (64 * 1024)
#define APP_THREAD_STACK_SIZE_MIN (48 * 1024)
#else
#define APP_THREAD_STACK_SIZE_DEFAULT (32 * 1024)
#define APP_THREAD_STACK_SIZE_DEFAULT (64 * 1024)
#define APP_THREAD_STACK_SIZE_MIN (24 * 1024)
#endif
#endif /* end of !(defined(APP_THREAD_STACK_SIZE_DEFAULT) \

View File

@ -5,6 +5,8 @@
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <pthread.h>
#ifdef __wasi__
#include <wasi/api.h>
#include <sys/socket.h>
@ -39,11 +41,27 @@ test_nslookup(int af)
freeaddrinfo(res);
}
void *
test_nslookup_mt(void *params)
{
int *af = (int *)params;
test_nslookup(*af);
}
int
main()
{
test_nslookup(AF_INET); /* for ipv4 */
test_nslookup(AF_INET6); /* for ipv6 */
int afs[] = { AF_INET, AF_INET6 };
for (int i = 0; i < sizeof(afs) / sizeof(afs[0]); i++) {
pthread_t th;
printf("Testing %d in main thread...\n", afs[i]);
test_nslookup(afs[i]);
printf("Testing %d in a new thread...\n", afs[i]);
pthread_create(&th, NULL, test_nslookup_mt, &afs[i]);
pthread_join(th, NULL);
}
return 0;
}