Skip to content

Thread panic is not handled #320

@zjp-CN

Description

@zjp-CN

#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
error!("{}", info);
axhal::power::system_off()
}

ArceOS just powers off when a spanwed thread panics:

// axstd = { workspace = true, features = ["multitask"] }
#![no_std]
#![no_main]

use axstd::{println, thread};

#[unsafe(no_mangle)]
fn main() {
    _ = thread::spawn(|| panic!("thread spawned")).join();
    println!("main thread ends"); // This never runs.
}
[  0.014810 0:4 axruntime::lang_items:5] panicked at examples/helloworld/src/main.rs:8:26:
thread spawned

The panic shouldn't terminate main thread in ArceOS.

This playground link shows how libstd API behaves.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions