Forráskód Böngészése

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;
}
```
Marcin Kolny 2 éve
szülő
commit
6ed4c9c908
2 módosított fájl, 21 hozzáadás és 3 törlés
  1. 1 1
      core/config.h
  2. 20 2
      core/iwasm/libraries/lib-socket/test/nslookup.c

+ 1 - 1
core/config.h

@@ -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) \

+ 20 - 2
core/iwasm/libraries/lib-socket/test/nslookup.c

@@ -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;
 }