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

Simplify preserve list approach #364

Merged
merged 5 commits into from
Jul 28, 2024

Conversation

DavisVaughan
Copy link
Member

@DavisVaughan DavisVaughan commented Jul 26, 2024

Closes #249 as a cool side effect

The preserved static struct object has been removed in favor of some inline functions detail::store::insert() and detail::store::release(). These both access the preserve list through a static local SEXP in an extern function called detail::store::get(). This exact setup is guaranteed by the standard to mean that the preserve list is unique across compilation units in the package (see notes and links to SO and the standard in protect.hpp).

While working on #366, I learned that the current approach with the static preserved seems to have some issues anyways. The tests I implemented there were not consistently passing on all platforms, and seemed to change on my Mac depending on whether or not I compiled with optimization, making me think we were in undefined behavior land previously. I confirmed that everything works as expected with this new standard approved approach.

And finally provide some reasoning backed by the standard about how the preserve list is unique across the compilation units in the package!
@DavisVaughan DavisVaughan force-pushed the feature/simpler-preserve-list branch from 9b5f6dd to ff2d750 Compare July 28, 2024 17:02
@DavisVaughan DavisVaughan merged commit 67a92bb into r-lib:main Jul 28, 2024
16 checks passed
@DavisVaughan DavisVaughan deleted the feature/simpler-preserve-list branch July 28, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid warning about cpp11::perserved, e.g.
1 participant