Skip to content
This repository has been archived by the owner on Apr 5, 2024. It is now read-only.

Implement the THIR unsafety checker #7

Closed
13 tasks done
LeSeulArtichaut opened this issue Mar 14, 2021 · 2 comments
Closed
13 tasks done

Implement the THIR unsafety checker #7

LeSeulArtichaut opened this issue Mar 14, 2021 · 2 comments
Assignees

Comments

@LeSeulArtichaut LeSeulArtichaut added this to Active 🟢 in THIR Unsafeck Plan Mar 14, 2021
@LeSeulArtichaut LeSeulArtichaut self-assigned this Mar 14, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue May 13, 2021
…matsakis

Introduce the beginning of a THIR unsafety checker

This poses the foundations for the THIR unsafety checker, so that it can be implemented incrementally:
- implements a rudimentary `Visitor` for the THIR (which will definitely need some tweaking in the future)
- introduces a new `-Zthir-unsafeck` flag which tells the compiler to use THIR unsafeck instead of MIR unsafeck
- implements detection of unsafe functions
- adds revisions to the UI tests to test THIR unsafeck alongside MIR unsafeck

This uses a very simple query design, where bodies are unsafety-checked on a body per body basis. This however has some big flaws:
- the unsafety-checker builds the THIR itself, which means a lot of work is duplicated with MIR building constructing its own copy of the THIR
- unsafety-checking closures is currently completely wrong: closures should take into account the "safety context" in which they are created, here we are considering that closures are always a safe context

I had intended to fix these problems in follow-up PRs since they are always gated under the `-Zthir-unsafeck` flag (which is explicitely noted to be unsound).

r? `@nikomatsakis`
cc rust-lang/project-thir-unsafeck#3 rust-lang/project-thir-unsafeck#7
@LeSeulArtichaut
Copy link
Contributor Author

@Smittyvb thanks for your help on this! If you plan on working on more unsafe operations, it would be great if you posted a comment here saying that you're doing it so we don't risk duplicate work. Or, if you intend to work regularly on this, you can ask to join the project group so you can edit the comment above directly.

bors added a commit to rust-lang-ci/rust that referenced this issue May 16, 2021
…nikomatsakis

Check for inline assembly in THIR unsafeck

rust-lang#83129 was merged recently and added a THIR unsafe checker. This adds a check for inline assembly. (and this is 2x simpler than the MIR version, which has to check for `asm` and `llvm_asm` in two separate spots!)

 see also rust-lang/project-thir-unsafeck#7
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 21, 2021
…komatsakis

Add DerefOfRawPointer and CallToFunctionWith to THIR unsafeck

Extends THIR unsafeck to check for two more cases of unsafe operations: dereferences of raw pointers and calls to functions with `#[target_feature]` (RFC 2396). The check for the latter is pretty much copy-pasted from the existing MIR equivalent.

This will clash with rust-lang#83842 and rust-lang#85273 which are arguably more important, let's maybe focus on getting those merged first, this can wait.
r? `@nikomatsakis`
cc rust-lang/project-thir-unsafeck#7
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this issue May 21, 2021
…nikomatsakis

Check for use of mutable/extern statics in THIR unsafeck

Extends THIR unsafeck to check for use of mutable and extern statics.

r? `@ghost` (I don't want to flood Niko's review queue)
cc rust-lang/project-thir-unsafeck#7
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 9, 2021
…=oli-obk

Check for union field accesses in THIR unsafeck

see also rust-lang#85259, rust-lang#83129, rust-lang/project-thir-unsafeck#7

r? `@LeSeulArtichaut`
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 13, 2021
…k, r=oli-obk

Implement Mutation- and BorrowOfLayoutConstrainedField in thir-unsafeck

Since nobody has so far claimed Mutation- and BorrowOfLayoutConstrainedField in rust-lang/project-thir-unsafeck#7, I have taken the liberty of implementing them in thir-unsafeck.

r? `@LeSeulArtichaut`
LeSeulArtichaut added a commit to LeSeulArtichaut/rust that referenced this issue Jul 24, 2021
…on, r=oli-obk

Implement `AssignToDroppingUnionField` in THIR unsafeck

r? `@oli-obk` cc rust-lang/project-thir-unsafeck#7
Manishearth added a commit to Manishearth/rust that referenced this issue Jul 24, 2021
…on, r=oli-obk

Implement `AssignToDroppingUnionField` in THIR unsafeck

r? ``@oli-obk`` cc rust-lang/project-thir-unsafeck#7
@syvb
Copy link

syvb commented Jul 24, 2021

@LeSeulArtichaut It appears that all of the unsafe operations have been implemented, I think this should be closed.

@LeSeulArtichaut LeSeulArtichaut moved this from Active 🟢 to Done ✅ in THIR Unsafeck Plan Jul 24, 2021
m-ou-se added a commit to m-ou-se/rust that referenced this issue Aug 23, 2021
…eck, r=oli-obk

Do not mark `-Z thir-unsafeck` as unsound anymore

The initial implementation of the THIR unsafety checker is now complete (rust-lang/project-thir-unsafeck#7).

r? `@oli-obk`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
Development

No branches or pull requests

2 participants