diff options
| author | Chester guo <[email protected]> | 2022-02-17 00:44:37 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-02-17 00:44:37 +0800 |
| commit | 01b3a34cc6828a87d1f365502a78dca5eadce00c (patch) | |
| tree | e072fdfd681e5b5a9593b0bcb7bdb71b39337a20 | |
| parent | 49ccbdb85199a6aa33b559856e6ed9e4328e62b9 (diff) | |
[Fix bug] fix thread init bug (#4891)
When we create thread A by rt_thread_init but do
not init the thread object,and then create thread
B in the thread A,it maybe crash.
| -rwxr-xr-x[-rw-r--r--] | src/thread.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/thread.c b/src/thread.c index 30208f1dd1..79f4eb5f07 100644..100755 --- a/src/thread.c +++ b/src/thread.c @@ -191,6 +191,12 @@ static rt_err_t _thread_init(struct rt_thread *thread, thread->current_priority = priority; thread->number_mask = 0; + +#ifdef RT_USING_EVENT + thread->event_set = 0; + thread->event_info = 0; +#endif + #if RT_THREAD_PRIORITY_MAX > 32 thread->number = 0; thread->high_mask = 0; @@ -247,6 +253,13 @@ static rt_err_t _thread_init(struct rt_thread *thread, thread->duration_tick = 0; #endif + +#ifdef RT_USING_MODULE + thread->module_id = 0; +#endif + + thread->user_data = 0; + RT_OBJECT_HOOK_CALL(rt_thread_inited_hook, (thread)); return RT_EOK; |
