Skip to content

use of parking_lot send_guard feature prevents use of deadlock_detection in overall program #553

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

Open
wez opened this issue Apr 2, 2025 · 1 comment

Comments

@wez
Copy link
Contributor

wez commented Apr 2, 2025

Not sure what you think of this, but I'm trying to track down an issue that manifests like a deadlock, and I'd like to use parking_lot's deadlock_detection feature to to see if it can help with this.

The use of send_guard here in mlua when send is enabled is not compatible with that feature and prevents the program from compiling with a compile error.

If I build against mlua from git with this quick and dirty patch:

diff --git a/Cargo.toml b/Cargo.toml
index 91f373b..82c071b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -38,7 +38,8 @@ luau-vector4 = ["luau", "ffi/luau-vector4"]
 vendored = ["ffi/vendored"]
 module = ["dep:mlua_derive", "ffi/module"]
 async = ["dep:futures-util"]
-send = ["parking_lot/send_guard", "error-send"]
+send = ["error-send"]
 error-send = []
 serialize = ["dep:serde", "dep:erased-serde", "dep:serde-value", "bstr/serde"]
 macros = ["mlua_derive/macros"]

then my overall program continues to compile and will allow me to enable deadlock_detection.

Can we find a way to allow the embedding program to opt-in or opt-out of using send_guard?

AFAICT from a quick look, it was added in #147 to facilitate external usage, so it doesn't appear as though mlua requires that feature at all.

Thanks!

@khvzak
Copy link
Member

khvzak commented Apr 5, 2025

The parking_lot/send_guard is needed only for userdata-wrappers feature (if remove parking_lot/send_guard and add userdata-wrappers then mlua would not compile).

This is because (when userdata-wrappers is enabled), the UserDataRef<T> can hold MutexGuard, which is Send-able only when GuardMarker: Send

Unfortunately there is not way to say in Cargo.toml that when both send and userdata-wrappers are enabled, add parking_lot/send_guard requirement.

I probably can move send_guard to userdata-wrappers = ["parking_lot/send_guard"] which makes more sense?

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

2 participants