Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport v3.5-branch] Add CODE_UNREACHABLE after k_thread_abort(k_current_get()) #64285

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/posix/pthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@ void pthread_exit(void *retval)
/* not a valid posix_thread */
LOG_DBG("Aborting non-pthread %p", k_current_get());
k_thread_abort(k_current_get());

CODE_UNREACHABLE;
}

/* Make a thread as cancelable before exiting */
Expand Down
2 changes: 2 additions & 0 deletions samples/modules/tflite-micro/tflm_ethosu/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ void inferenceProcessTask(void *_name, void *heap, void *_params)
}

k_thread_abort(k_current_get());

CODE_UNREACHABLE;
}

/* inferenceSenderTask - Creates NUM_INFERENCE_JOBS jobs, queues them, and then
Expand Down
2 changes: 2 additions & 0 deletions subsys/shell/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -1307,6 +1307,8 @@ static void kill_handler(const struct shell *sh)

sh->ctx->tid = NULL;
k_thread_abort(k_current_get());

CODE_UNREACHABLE;
}

void shell_thread(void *shell_handle, void *arg_log_backend,
Expand Down
5 changes: 5 additions & 0 deletions subsys/testsuite/ztest/src/ztest.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,12 @@ static void test_finalize(void)
{
if (IS_ENABLED(CONFIG_MULTITHREADING)) {
k_thread_abort(&ztest_thread);
if (k_is_in_isr()) {
return;
}

k_thread_abort(k_current_get());
CODE_UNREACHABLE;
}
}

Expand Down
2 changes: 2 additions & 0 deletions subsys/testsuite/ztest/src/ztest_error_hook.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ static inline void z_vrfy_ztest_set_assert_valid(bool valid)
__weak void ztest_post_assert_fail_hook(void)
{
k_thread_abort(k_current_get());

CODE_UNREACHABLE;
}

#ifdef CONFIG_ASSERT_NO_FILE_INFO
Expand Down
5 changes: 5 additions & 0 deletions subsys/testsuite/ztest/src/ztest_new.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,12 @@ static void test_finalize(void)
{
if (IS_ENABLED(CONFIG_MULTITHREADING)) {
k_thread_abort(&ztest_thread);
if (k_is_in_isr()) {
return;
}

k_thread_abort(k_current_get());
CODE_UNREACHABLE;
}
}

Expand Down
2 changes: 2 additions & 0 deletions tests/kernel/sched/deadline/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ void yield_worker(void *p1, void *p2, void *p3)
zassert_true(n_exec == NUM_THREADS, "");

k_thread_abort(k_current_get());

CODE_UNREACHABLE;
}

ZTEST(suite_deadline, test_yield)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ static void thread_entry_abort(void *p1, void *p2, void *p3)
/**TESTPOINT: abort current thread*/
execute_flag = 1;
k_thread_abort(k_current_get());
CODE_UNREACHABLE;
/*unreachable*/
execute_flag = 2;
zassert_true(1 == 0);
Expand Down