Просмотр исходного кода

fixed(freertos): Fix crash when wasm app call pthread_exit(NULL) (#2970)

before the change, only support wasm app exit like:
```c
void *thread_routine(void *arg)
{
    printf("Enter thread\n");
    return NULL;
}
```
if call pthread_exit, it will crash:
```c
void *thread_routine(void *arg)
{
    printf("Enter thread\n");
    pthread_exit(NULL);
    return NULL;
}
```
This commit lets both upstairs work correctly, test pass on stm32f103 mcu.
tkernelcn 2 лет назад
Родитель
Сommit
286ea35508
1 измененных файлов с 29 добавлено и 1 удалено
  1. 29 1
      core/shared/platform/common/freertos/freertos_thread.c

+ 29 - 1
core/shared/platform/common/freertos/freertos_thread.c

@@ -205,7 +205,6 @@ os_thread_wrapper(void *arg)
 
     thread_data->start_routine(thread_data->arg);
     os_thread_cleanup();
-    vTaskDelete(NULL);
 }
 
 int
@@ -301,6 +300,22 @@ os_thread_join(korp_tid thread, void **value_ptr)
     return BHT_OK;
 }
 
+int
+os_thread_detach(korp_tid thread)
+{
+    /* Do nothing */
+    (void)thread;
+    return BHT_OK;
+}
+
+void
+os_thread_exit(void *retval)
+{
+    (void)retval;
+    os_thread_cleanup();
+    vTaskDelete(NULL);
+}
+
 int
 os_mutex_init(korp_mutex *mutex)
 {
@@ -469,3 +484,16 @@ os_cond_broadcast(korp_cond *cond)
 
     return BHT_OK;
 }
+
+uint8 *
+os_thread_get_stack_boundary()
+{
+    /* TODO: get freertos stack boundary */
+    return NULL;
+}
+
+void
+os_thread_jit_write_protect_np(bool enabled)
+{
+    (void)enabled;
+}