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

runtime: allow panic on syscall.Exit instead of halting #4010

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Commits on Nov 25, 2023

  1. runtime: allow panic on syscall.Exit instead of halting

    In some environments, such as u-root, code can be imported which
    provides a shell. The shell calls functions, instead of trying
    to use exec.Command (which is not available). An example
    can be found in github.com:u-root/u-root/tools/tinygobb.
    
    When the command exits, the shell needs to resume operation,
    which is not possible when runtime.Exit calls halt.
    
    On tamago, we achieve this by setting a normally nil
    function, runtime.Exit, to a funtion which panics. The
    shell has a recover() to catch the panics.
    
    There are many ways in which setting runtime.Exit can go wrong,
    including different functions setting it to different functions.
    
    tinygo allows a simpler, and hence more robust, model: instead
    of halting, we can panic. But in most cases, halting is ok.
    
    Add a function, runtime.PanicOnExit, which enables a panic
    on exit. This function is idempotent, and once panic on exit
    is enabled, it can not be disabled. This is restrictive
    by design. It is hoped that by making it simple and non-revocable,
    we can avoid the problems that can occur with more complex
    mechanisms, but still provide an option to halting.
    
    A function is provided, instead of just a variable, to allow
    simpler access from assembly, i.e., both variables and
    functions have been used in bare metal environments and, for
    several reasons, functions have proved more flexible.
    
    Signed-off-by: Ronald G. Minnich <[email protected]>
    rminnich committed Nov 25, 2023
    Configuration menu
    Copy the full SHA
    583411a View commit details
    Browse the repository at this point in the history