mirror of
				https://github.com/bytecodealliance/wasm-micro-runtime.git
				synced 2025-10-31 13:17:31 +00:00 
			
		
		
		
	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:
		
							parent
							
								
									569f702ec2
								
							
						
					
					
						commit
						6ed4c9c908
					
				|  | @ -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) \ | ||||
|  |  | |||
|  | @ -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; | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Marcin Kolny
						Marcin Kolny