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

promote debug_assert to assert when possible and useful #99624

Merged
merged 1 commit into from
Aug 12, 2022

Conversation

vincenzopalazzo
Copy link
Member

@vincenzopalazzo vincenzopalazzo commented Jul 22, 2022

This PR fixed a very old issue #94705 to clarify and improve the POSIX error checking, and some of the checks are skipped because can have no benefit, but I'm sure that this can open some interesting discussion.

Fixes #94705

cc: @tavianator
cc: @cuviper

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Jul 22, 2022
@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rustbot
Copy link
Collaborator

rustbot commented Jul 22, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 22, 2022
@rust-log-analyzer

This comment has been minimized.

@Mark-Simulacrum
Copy link
Member

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 23, 2022
@bors
Copy link
Contributor

bors commented Jul 23, 2022

⌛ Trying commit 9c5fc6726f5744deafd45eb4dda5b1ab52cfa8bd with merge f5809960996c3d9abb4b32698a720c41a619be38...

@bors
Copy link
Contributor

bors commented Jul 24, 2022

☀️ Try build successful - checks-actions
Build commit: f5809960996c3d9abb4b32698a720c41a619be38 (f5809960996c3d9abb4b32698a720c41a619be38)

@rust-timer
Copy link
Collaborator

Queued f5809960996c3d9abb4b32698a720c41a619be38 with parent 93ffde6, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (f5809960996c3d9abb4b32698a720c41a619be38): comparison url.

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: 😿 relevant regressions found
mean1 max count2
Regressions 😿
(primary)
1.4% 1.4% 1
Regressions 😿
(secondary)
2.8% 3.3% 5
Improvements 🎉
(primary)
-4.0% -4.0% 1
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) -1.3% -4.0% 2

Cycles

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: 🎉 relevant improvement found
mean1 max count2
Regressions 😿
(primary)
2.7% 2.7% 1
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
-2.2% -2.2% 1
Improvements 🎉
(secondary)
-3.2% -3.2% 1
All 😿🎉 (primary) 0.2% 2.7% 2

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never
@rustbot label: +S-waiting-on-review -S-waiting-on-perf -perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jul 24, 2022
@vincenzopalazzo vincenzopalazzo force-pushed the macros/unix_error branch 2 times, most recently from 4571565 to a278a74 Compare July 24, 2022 14:10
@vincenzopalazzo vincenzopalazzo force-pushed the macros/unix_error branch 3 times, most recently from cd128aa to c8c04e2 Compare July 24, 2022 14:56
@Mark-Simulacrum
Copy link
Member

r? @Amanieu for the interaction with panic-in-Drop = abort -- there's a few asserts here that are in Drop impls.

@Amanieu
Copy link
Member

Amanieu commented Jul 31, 2022

I would prefer keeping these as debug_assert: POSIX says that these functions cannot fail, so these asserts would only trigger if we made a mistake in the call arguments (EBADF, EFAULT) or the system is fundamentally broken (in which case it is outside the scope of Rust's safety anyways).

Since these asserts will never fire in practice, panic-in-drop is irrelevant here.

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Aug 9, 2022
library/std/src/sys/unix/fs.rs Outdated Show resolved Hide resolved
@bors
Copy link
Contributor

bors commented Aug 10, 2022

⌛ Testing commit 6231d17513119ffbb2d7c4724b2fa28311e32fc5 with merge 548063328dc5e6d2435446a46dd13d7e85666777...

@bors
Copy link
Contributor

bors commented Aug 10, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 10, 2022
@rust-log-analyzer

This comment has been minimized.

@vincenzopalazzo vincenzopalazzo force-pushed the macros/unix_error branch 2 times, most recently from 04469b2 to 3dddcbe Compare August 10, 2022 16:21
@vincenzopalazzo
Copy link
Member Author

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rust-log-analyzer

This comment has been minimized.

Signed-off-by: Vincenzo Palazzo <[email protected]>
@Amanieu
Copy link
Member

Amanieu commented Aug 11, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Aug 11, 2022

📌 Commit d91dff3 has been approved by Amanieu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 11, 2022
@bors
Copy link
Contributor

bors commented Aug 12, 2022

⌛ Testing commit d91dff3 with merge 569788e...

@bors
Copy link
Contributor

bors commented Aug 12, 2022

☀️ Test successful - checks-actions
Approved by: Amanieu
Pushing 569788e to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Aug 12, 2022
@bors bors merged commit 569788e into rust-lang:master Aug 12, 2022
@rustbot rustbot added this to the 1.65.0 milestone Aug 12, 2022
@RalfJung
Copy link
Member

POSIX says that these functions cannot fail

That's the thing, just because POSIX doesn't list an error doesn't mean the function cannot raise the error -- error lists are not exhaustive. See #94705.

@vincenzopalazzo
Copy link
Member Author

I agree with you @RalfJung I do not care if the docs tell us that this will not fail at all, a sanity check is always good.

However the majority of the review point in the way to do not add this promotion assert! I'm open to discuss it, but I think before reopen the issue we need to converge on trusting the POSIX docs or not otherwise work on this simple change will be super confusing because i like a ping pong game you add and revert the change!

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (569788e): comparison url.

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
3.4% 3.4% 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-4.1% -4.1% 1
All ❌✅ (primary) - - 0

Cycles

Results
  • Primary benchmarks: ❌ relevant regression found
  • Secondary benchmarks: no relevant changes found
mean1 max count2
Regressions ❌
(primary)
4.4% 4.4% 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 4.4% 4.4% 1

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

@RalfJung
Copy link
Member

The issue should remain open until we decided for good one way or the other, but I agree that things should be discussed on the issue before another PR is opened.

@vincenzopalazzo
Copy link
Member Author

The issue should remain open until we decided for good one way or the other, but I agree that things should be discussed on the issue before another PR is opened.

Maybe it is good to create a zulip thread for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

stdlib makes assumptions about errors returned by POSIX functions