Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Ensure proper panic handling of Rust code #47

Copy link
Copy link
Open
@wprzytula

Description

@wprzytula
Issue body actions

Background

Rust driver panics in various scenarios, mainly if a bug is encountered in the driver's code or when the API is heavily misused.

Problem statement

We need to ensure that if Rust driver (or any other Rust code) panics, Undefined Behaviour is not triggered and we understand what happens.

Useful resources

FFI (Foreign Function Interface) is (most likely, let's check it) the interface that napi-rs leverages to interface with NodeJS.
When stack-unwinding panics occur and cross the language boundary, various things can happen based on used extern ABI.
See rustonomicon for more details.

Simplest possible solution

Use panic=abort in Cargo.toml. Then a panic, instead of unwinding, aborts the process immediately.

This has a significant disadvantage: the printed debug message is limited to only the LoC where the panic was thrown, but there is no backtrace attached. This makes debugging much harder.

Another approach, which preserves backtraces

Use panic=unwind in Cargo.toml (the implicit default). Then a panic unwinds up until the language FFI boundary and then the program is aborted (hopefully after the backtrace is printed - let's verify that).

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low priority.Low priority.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.