Skip to content

Lint against invalid POSIX symbol definitions#158522

Open
Urgau wants to merge 3 commits into
rust-lang:mainfrom
Urgau:runtime-symbols-posix
Open

Lint against invalid POSIX symbol definitions#158522
Urgau wants to merge 3 commits into
rust-lang:mainfrom
Urgau:runtime-symbols-posix

Conversation

@Urgau

@Urgau Urgau commented Jun 28, 2026

Copy link
Copy Markdown
Member

This PR extends the invalid_runtime_symbol_definitions and suspicious_runtime_symbol_definitions lints to lint againts the following POSIX symbols:

  • I/O: open, read, write, close
  • Alloc: malloc, realloc, free
  • Program: exit

This is meant to address the multiple reports of users tripping over std symbols:

Those symbols are defined in std, so as long as the std crate is imported (and we are on a UNIX-like target) we lint on those symbols.

Follow up to #155521

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 28, 2026
@rustbot

rustbot commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

r? @chenyukang

rustbot has assigned @chenyukang.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 73 candidates
  • Random selection from 18 candidates

@Urgau Urgau changed the title Lint lint against invalid POSIX symbol definitions Lint against invalid POSIX symbol definitions Jun 28, 2026
@Urgau Urgau added the I-lang-nominated Nominated for discussion during a lang team meeting. label Jun 28, 2026
@Urgau Urgau force-pushed the runtime-symbols-posix branch from 315bb46 to 070c3d9 Compare June 28, 2026 12:41
@rust-log-analyzer

This comment has been minimized.

@rustbot

rustbot commented Jun 28, 2026

Copy link
Copy Markdown
Collaborator

miri is developed in its own repository. If possible, consider making this change to rust-lang/miri instead.

cc @rust-lang/miri

@traviscross traviscross added T-lang Relevant to the language team needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang I-lang-radar Items that are on lang's radar and will need eventual work or consideration. labels Jul 1, 2026
@traviscross

Copy link
Copy Markdown
Contributor

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

@rust-rfcbot

rust-rfcbot commented Jul 1, 2026

Copy link
Copy Markdown
Collaborator

@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.
See this document for info about what commands tagged team members can give me.

@rust-rfcbot rust-rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. and removed needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. labels Jul 1, 2026
@joshtriplett

Copy link
Copy Markdown
Member

@rfcbot reviewed

@joshtriplett joshtriplett added the relnotes Marks issues that should be documented in the release notes of the next release. label Jul 1, 2026
@traviscross traviscross removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Jul 1, 2026
@joshtriplett

Copy link
Copy Markdown
Member

Tagging relnotes as a reminder to extend the release notes on this lint to list the additional symbols.

@rust-rfcbot rust-rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Jul 1, 2026
@rust-rfcbot

Copy link
Copy Markdown
Collaborator

🔔 This is now entering its final comment period, as per the review above. 🔔

@rust-rfcbot rust-rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Jul 1, 2026
@@ -0,0 +1,27 @@
// This test makes sure that the following symbols are not linked against

@ogoffart ogoffart Jul 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did you mean

Suggested change
// This test makes sure that the following symbols are not linked against
// This test makes sure that the following symbols are not linted against

View changes since the review

ExpectedSymbol { symbol: "bcmp", lang: LanguageItems::bcmp_fn },
ExpectedSymbol { symbol: "strlen", lang: LanguageItems::strlen_fn },
// POSIX symbols
ExpectedSymbol { symbol: "open", lang: LanguageItems::open_fn },

@chenyukang chenyukang Jul 8, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A definition of open64 with the wrong signature would still bypass the lint?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-lang Relevant to the language team T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants