Document unwinding ABI extern "C"

Open
#672 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Documentation
Clarity
Mostly clear
Activity status
Stale
Tech stack
rust
Domain
documentation

Research direction

Start with the Rust Reference entry for the extern "C" ABI and trace the documentation history from the referenced commit. Review issue #48251 and the linked LLVM discussion to establish the intended platform-dependent unwinding behavior. Done means the reference clearly documents the behavior or records the unresolved decision.

Written by the indexing model from the issue text.

Description

A-abi

The current documentation of the extern "C" ABI in the reference says:

extern "C" -- This is the same as extern fn foo(); whatever the default your C compiler supports.

When it comes to whether C functions can unwind, the C compiler defaults on most platforms is that these cannot unwind. An exception is MSVC, where AFAICT all functions can always unwind (e.g. even C++ noexcept functions are allowed to be unwound by specific exceptions like, e.g., the one thrown by longjmp).

If this is actually the intended behavior we probably should not emit nounwind for extern "C" functions on Windows. That would have fixed https://github.com/rust-lang/rust/issues/48251 in a different way since that would have allowed longjmps from C into Rust. In the LLVM issue different strategies to allowing nounwind there but fixing things at the LLVM level are being discussed: https://bugs.llvm.org/show_bug.cgi?id=36508.

So as written, whether extern "C" functions can unwind is platform dependent. Is this the intended behavior ? If so, we should clarify this. The earliest I can trace this documentation is https://github.com/rust-lang-nursery/reference/commit/3461ff1feb4956f168c74c9a906af2c61410b080

cc @Centril @nagisa @eddyb

Dominant language
Rust
Stars
1.6k
Forks
607
Avg merge
1d 1h
Merged PRs (30d)
12

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rust-lang/reference

All issues in rust-lang/reference

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.