Skip to content

TRPL: FFI: address panics #26455

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

Merged
merged 1 commit into from
Jun 21, 2015
Merged

TRPL: FFI: address panics #26455

merged 1 commit into from
Jun 21, 2015

Conversation

steveklabnik
Copy link
Member

Fixes #26443

r? @gankro

# fn main() {}
```

If you’re writing code that may panic, you should run it in an other thread,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/an other/another

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors r+ rollup

On Sat, Jun 20, 2015 at 11:19 AM, Steve Klabnik [email protected]
wrote:

In src/doc/trpl/ffi.md
#26455 (comment):

@@ -530,3 +530,37 @@ The extern makes this function adhere to the C calling convention, as
discussed above in "Foreign Calling
Conventions
". The no_mangle
attribute turns off Rust's name mangling, so that it is easier to link to.
+
+# FFI and panics
+
+It’s important to be mindful of panic!s when working with FFI. This code,
+when called from C, will abort:
+
+```rust
+#[no_mangle]
+pub extern fn oh_no() -> ! {

  • panic!("Oops!");
    +}
    +# fn main() {}
    +```

+If you’re writing code that may panic, you should run it in an other thread,

fixed


Reply to this email directly or view it on GitHub
https://github.com/rust-lang/rust/pull/26455/files#r32886642.

@Gankra
Copy link
Contributor

Gankra commented Jun 20, 2015

I'm not sure if this is in the scope or style or TRPL, but I think it would be worth noting that having to spawn a thread is a temporary measure while we work out our story here.

@steveklabnik
Copy link
Member Author

steveklabnik commented Jun 20, 2015 via email

@steveklabnik
Copy link
Member Author

@bors: r=gankro rollup

@bors
Copy link
Collaborator

bors commented Jun 20, 2015

📌 Commit 24c1e10 has been approved by gankro

@bors
Copy link
Collaborator

bors commented Jun 21, 2015

⌛ Testing commit 24c1e10 with merge 1ec599c...

bors added a commit that referenced this pull request Jun 21, 2015
@bors bors merged commit 24c1e10 into rust-lang:master Jun 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants