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

Remove dubious thread assertion #562

Merged
merged 2 commits into from
May 17, 2022
Merged

Conversation

workingjubilee
Copy link
Member

This assertion is misleading: if the Rust runtime becomes nested,
it creates a "new" thread, without actually spawning a second thread.
This debug_assert! then yields erroneous assertions.

This assertion is misleading: if the Rust runtime becomes nested,
it creates a "new" thread, without actually spawning a second thread.
This debug_assert! then yields erroneous assertions.
Copy link
Contributor

@Hoverbear Hoverbear left a comment

Choose a reason for hiding this comment

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

Is there a way for us to guard at all?

@workingjubilee
Copy link
Member Author

These are only debug asserts to begin with, so they only work if they are part of testing, but: not without completely revising the way we approach this, and probably not in a way that we would reasonably consider "trustworthy".

That is, we could simply check if we share the identity of a Rust main thread. But this seems easily forged, so it would be more security theater than security wall.

@@ -76,17 +76,6 @@ fn take_panic_location() -> PanicLocation {
thread_local! { pub(crate) static IS_MAIN_THREAD: once_cell::sync::OnceCell<()> = once_cell::sync::OnceCell::new() }
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems we should remove this too.

Copy link
Member Author

@workingjubilee workingjubilee May 16, 2022

Choose a reason for hiding this comment

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

I was slightly more hesitant to remove all of that machinery because it seemed more possibly-useful. But if you are confident that it is okay to remove, I will happily do so!

@eeeebbbbrrrr
Copy link
Contributor

These are only debug asserts to begin with, so they only work if they are part of testing, but: not without completely revising the way we approach this, and probably not in a way that we would reasonably consider "trustworthy".

That is, we could simply check if we share the identity of a Rust main thread. But this seems easily forged, so it would be more security theater than security wall.

Yeah, this was an ill-considered thing from the beginning. The intention was just to let the programmer know they used a Postgres-internal function in a background thread. Ya know, just to be "helpful".

As we work towards the "postgrestd" stuff, I'm imagining that std::thread won't even be available, so...

@workingjubilee
Copy link
Member Author

I imagine we might offer the facilities for naming the current thread, but probably not spawning one unless we can somehow make sure things go through a properly reentrant interface.

@workingjubilee workingjubilee dismissed eeeebbbbrrrr’s stale review May 17, 2022 20:01

Eric is currently out, and his comments were addressed. I will happily followup on anything needing fixing.

@workingjubilee workingjubilee merged commit b7cbc3f into develop May 17, 2022
@eeeebbbbrrrr eeeebbbbrrrr deleted the weaken-thread-guard branch June 20, 2023 18:01
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.

3 participants