Skip to content
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

Can bypass repr(packed) checking by using --cap-lints #26

Closed
taiki-e opened this issue Sep 8, 2020 · 2 comments
Closed

Can bypass repr(packed) checking by using --cap-lints #26

taiki-e opened this issue Sep 8, 2020 · 2 comments
Labels
C-bug Category: related to a bug. C-upstream-bug Category: This is a bug of compiler or dependencies (the fix may require action in the upstream) I-unsound A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness

Comments

@taiki-e
Copy link
Owner

taiki-e commented Sep 8, 2020

NOTE: pin-project (not lite) is not affected by this issue. see taiki-e/pin-project#34 (comment) for more.
EDIT: see taiki-e/pin-project#342 for pin-project (not lite)

Currently, pin-project-lite uses safe_packed_borrow lint to check that the struct is not repr(packed). Unfortunately, safe_packed_borrow is lint and you can use the rustc's --cap-lints flag to lower the lint cap level: https://godbolt.org/z/jEf1fG

The current pin-project-lite generates almost the same code as pin-project, but does not have the equivalent of the repr(packed) checking that proc-macro(pin-project) does during expansion. (Since the proc-macro-attribute used on the struct expand later than declarative macro used for the struct, a complete fix for the problem is probably impossible until safe_packed_borrow gets a hard error.)

@taiki-e taiki-e added C-bug Category: related to a bug. I-unsound A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness labels Sep 8, 2020
@RalfJung
Copy link

RalfJung commented Sep 8, 2020

FWIW, safe_packed_borrow should become a hard error eventually. However, that cannot happen before we stabilize rust-lang/rust#73394 (and then wait some time).

bors bot added a commit that referenced this issue Mar 2, 2021
55: Prepare for removal of safe_packed_borrows lint r=taiki-e a=taiki-e

pin-project-lite is using `safe_packed_borrows` lint for checking `repr(packed)` types. (See taiki-e/pin-project#34 for more)

As described in #26, lint-based tricks aren't perfect, but they're much better than nothing.

`safe_packed_borrows` is planned to be removed in favor of `unaligned_references` (rust-lang/rust#82525), so I would like to switch to `unaligned_references`. (However, actually, enable both lint as `unaligned_references` does not exist in older compilers.)

Co-authored-by: Taiki Endo <[email protected]>
@taiki-e taiki-e added the S-blocked Status: Blocked on something else label Jun 14, 2021
@taiki-e taiki-e added the C-upstream-bug Category: This is a bug of compiler or dependencies (the fix may require action in the upstream) label Mar 12, 2022
@taiki-e taiki-e removed the S-blocked Status: Blocked on something else label Feb 1, 2023
@taiki-e
Copy link
Owner Author

taiki-e commented Feb 1, 2023

unaligned_references is now a hard error 🎉: rust-lang/rust#102513

@taiki-e taiki-e closed this as completed Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: related to a bug. C-upstream-bug Category: This is a bug of compiler or dependencies (the fix may require action in the upstream) I-unsound A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
Projects
None yet
Development

No branches or pull requests

2 participants