betrusted-io / xous-core

The Xous microkernel
Apache License 2.0
529 stars 85 forks source link

`panic`: modals dialog box support for panic handler #132

Closed bunnie closed 2 years ago

bunnie commented 2 years ago

Quoting Matrix chat

bunnie If we didn't have a watchdog, if the system panics, then it'd just...sit there unresponsive. But if you didn't already have a debug cable attached, there would still be no way to extract the panic info? because the panic would have been printed to the serial console, and it would be missed you can't post-facto attach the debug cable to capture the data I think it would be neat to be able to try to shoot off a message to a dedicated panic renderer that would pop up a dialog box with a message tho if that happened

xobs It depends on the panic, but yeah for now panics can be considered to be catastrophic enough that they warrant a system reboot. The thing in libstd that does that is: https://github.com/betrusted-io/rust/blob/1.59.0-xous/library/std/src/sys/xous/stdio.rs#L141-L154 rust/stdio.rs at 1.59.0-xous · betrusted-io/rust - GitHub Empowering everyone to build reliable and efficient software. - rust/stdio.rs at 1.59.0-xous · betrusted-io/rust Rather than allocating a chunk of memory it sends the command through a series of scalar messages. bunnie allocs are forbidden in panics yes? I think i could make a dedicated thread in modals that pre-allocates everything it needs to render a panic message. xobs It depends on the panic, but yeah for now panics can be considered to be catastrophic enough that they warrant a system reboot. The thing in libstd that does that is: https://github.com/betrusted-io/rust/blob/1.59.0-xous/library/std/src/sys/xous/stdio.rs#L141-L154 rust/stdio.rs at 1.59.0-xous · betrusted-io/rust - GitHub Empowering everyone to build reliable and efficient software. - rust/stdio.rs at 1.59.0-xous · betrusted-io/rust Rather than allocating a chunk of memory it sends the command through a series of scalar messages.

bunnie allocs are forbidden in panics yes? I think i could make a dedicated thread in modals that pre-allocates everything it needs to render a panic message.

xobs Though now that I have developed the stack technique that we use e.g. https://github.com/betrusted-io/rust/blob/1.59.0-xous/library/std/src/sys/xous/net/mod.rs#L35-L38 then it becomes more possible to send large data across. Provided the error is a panic, and not due to running out of stack. rust/mod.rs at 1.59.0-xous · betrusted-io/rust - GitHub Empowering everyone to build reliable and efficient software. - rust/mod.rs at 1.59.0-xous · betrusted-io/rust

bunnie so the panic handler could try to print the message to the log server first, and then try to relay it to the modals handler for something that doesn't require a serial cable to see I feel like in the case of the panic, the serial panic is a good "last-line" but it wouldn't hurt as a supplemental effort to pop up a dialog box. in case of out of stack, it wouldn't work, but i'd say...99% of the panics I see right now aren't related to OOM conditions at all. Most of them are unhandled .unwrap() fails in complicated async comms routines. most of those could render to the screen just fine

xobs Then yeah, perhaps it's best to do it in two steps. Allocate the message on the stack as a 4096-byte message, then send it to the log server as an immutable borrow, and afterwards send it to the dialog server.

bunnie commented 2 years ago

link to chat for review

https://matrix.to/#/!NsnVDrDBdLREhyjNGd:matrix.org/$DJw3bV-dJKma95IvVTH9Gu3Tq4x4c4eGb73N1w7KcTM?via=matrix.org&via=tchncs.de&via=diem25.tech

bunnie commented 2 years ago

This will require:

bunnie commented 2 years ago

this is now pushed to main, closing.