Lint against invalid POSIX symbol definitions#158522
Conversation
|
r? @chenyukang rustbot has assigned @chenyukang. Use Why was this reviewer chosen?The reviewer was selected based on:
|
315bb46 to
070c3d9
Compare
This comment has been minimized.
This comment has been minimized.
|
cc @rust-lang/miri |
|
Makes sense to me. Included in this FCP is preapproval for extending this to all extern functions referenced by the standard library when linked, such that defining a function of the same name in your program with a mismatched signature would cause problems. @rfcbot fcp merge lang |
|
@traviscross has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
|
@rfcbot reviewed |
|
Tagging relnotes as a reminder to extend the release notes on this lint to list the additional symbols. |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
| @@ -0,0 +1,27 @@ | |||
| // This test makes sure that the following symbols are not linked against | |||
There was a problem hiding this comment.
Did you mean
| // This test makes sure that the following symbols are not linked against | |
| // This test makes sure that the following symbols are not linted against |
| ExpectedSymbol { symbol: "bcmp", lang: LanguageItems::bcmp_fn }, | ||
| ExpectedSymbol { symbol: "strlen", lang: LanguageItems::strlen_fn }, | ||
| // POSIX symbols | ||
| ExpectedSymbol { symbol: "open", lang: LanguageItems::open_fn }, |
There was a problem hiding this comment.
A definition of open64 with the wrong signature would still bypass the lint?
There was a problem hiding this comment.
Yes, only symbols defined in this list are checked, but given that T-lang wants to lint on all the functions used by core/std #158522 (comment) it makes sense to add open64 (and any other libc function) in a follow-up PR.
This PR extends the
invalid_runtime_symbol_definitionsandsuspicious_runtime_symbol_definitionslints to lint againts the following POSIX symbols:open,read,write,closemalloc,realloc,freeexitThis is meant to address the multiple reports of users tripping over
stdsymbols:#[no_mangle] fn open() {}makecargo thang?no_mangleThose symbols are defined in
std, so as long as thestdcrate is imported (and we are on a UNIX-like target) we lint on those symbols.Follow up to #155521