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

alloc-tls: how can panicking in with’s closure cause UB? #197

Open
cormacrelf opened this issue May 19, 2020 · 0 comments
Open

alloc-tls: how can panicking in with’s closure cause UB? #197

cormacrelf opened this issue May 19, 2020 · 0 comments

Comments

@cormacrelf
Copy link

I’ve read the code a few times and I don’t quite understand how the closure panicking could cause undefined behaviour. As far as I can tell, f is only ever called in “tail position”, after all the initialisation is done, even in with_slow. The TLSSlot passes it a pointer to the storage, wraps the result in Some and returns. There is no transient state that has to be cleaned up after it returns. There are no variables in scope with a Drop implementation in either with or with_slow. When you unwind it, it’s pretty much identical to having returned normally. How does it cause UB?

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

No branches or pull requests

1 participant