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

Fix 24208, 24212, 24213 - scope escape via pure + nested context #15756

Merged
merged 3 commits into from
Oct 30, 2023

Conversation

pbackus
Copy link
Contributor

@pbackus pbackus commented Oct 30, 2023

The compiler sometimes allows scope pointers to be passed to non-scope parameters of pure function, with the exact rules documented in this section of the language spec:

https://dlang.org/spec/function.html#pure-scope-inference

Unfortunately, when checking for parameters with mutable indirections that an argument could escape through, the compiler previously:

  • did not include variables accessed through the function's nested context, and
  • did not assume conservatively that escape was possible if the function had a context that could vary at runtime.

As a result, it was possible to escape a scope pointer in @safe code.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @pbackus! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
24208 normal [DIP1000] Scope pointer can escape via non-scope parameter of pure nested function
24212 normal [DIP1000] Scope pointer can escape via non-scope parameter of pure virtual function
24213 normal [DIP1000] Scope pointer can escape via non-scope parameter of pure delegate

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#15756"

* Issue 24212 - Scope pointer can escape via non-scope parameter of pure
  virtual function
* Issue 24213 - Scope pointer can escape via non-scope parameter of pure
  delegate
@pbackus
Copy link
Contributor Author

pbackus commented Oct 30, 2023

Force push to re-run CI in case the problem with FreeBSD 13 is transient.

@pbackus pbackus requested a review from ibuclaw as a code owner October 30, 2023 21:00
@thewilsonator
Copy link
Contributor

This is a safety bug, did you want to target stable?

@pbackus
Copy link
Contributor Author

pbackus commented Oct 30, 2023

There isn't another point release before 2.106, right? So it should be the same either way.

@thewilsonator thewilsonator merged commit 8de7c1e into dlang:master Oct 30, 2023
43 checks passed
@ibuclaw
Copy link
Member

ibuclaw commented Oct 31, 2023

There isn't another point release before 2.106, right? So it should be the same either way.

It's been a month since the last point release, so yes there might as well be another 2.105 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants