Skip to content

std::process::abort from FFI does not abort. #93276

@T4r4sB

Description

@T4r4sB

I know that panic unwinding from FFI is UB. But abort must terminate the program immediately, where can be problem here?

Let we have this code: https://github.com/janiorca/tinywin/blob/master/miniwin/src/main.rs
Try to add abort into WM_PAINT handler:

...
    match msg {
        winapi::um::winuser::WM_PAINT => {
            println!("abort");
            std::process::abort();
            ...

Try to run it (I use target i686_windows_gnu), and watch to console:

...
abort
abort
abort
abort
abort
abort
abort
abort
abort
abort
abort
abort
abort
...

Looks like abort called from WndProc doest not work.
In more complicated cases I cant write Winapi applications with "panic=abort" mode, because abort dont do what I want, and I need to write catch_unwind in std::panic, and generate unwinding boilerplate even in release mode and write std::process::exit(3) (which works correctly).

What's the problem with std::process::abort, and why in doesn't work from WndProc, but std::process:exit works good?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions