-
Notifications
You must be signed in to change notification settings - Fork 42
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 potentially dropped Client
in configure
#40
Conversation
On second read, I don't know whether this is safe. If this attempts to destroy the |
Oops, I didn't think of that. I would probably revert it and fix that with lifetime subtype/variance. |
I've fixed that by using lifetime subtyping to ensure that |
I think a better solution might be to use some sort of leaking method in the forked process. I'm wary to change the public API here and I'm not actually sure that this fixes the original issue (while it probably fixes the one specific example I'm not sure that this fixes all usages). |
That sounds like a good idea. I will do it tomorrow. |
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@alexcrichton I've fixed this by leaking the |
Reading over this, can you confirm the behavior one way or another? This now actually seems like it'll legitimately leak the memory in the host process. |
@alexcrichton According to
So this should be fine. |
I'm more worried about the |
Thanks for pointing out! Turns out that I missed that one :D |
Since `ManuallyDrop<Arc<Self>>` would also leak the `Arc` in parent, switch to using `Arc::increment_strong_count` instead. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@alexcrichton This should now be fixed as I use |
Looks good to me, can you expand in the comment why the arc is leaked though? |
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
|
Sorry yes I understand that this is being leaked, what I would like the code to document is why it's being leaked because in the abstract that's a pretty weird thing to do intentionally. |
Hmmm, let arc = mem::ManuallyDrop::new(unsafe { Arc::from_raw(p.0) });
let _arc_clone: mem::ManuallyDrop<_> = arc.clone(); |
Basically, Using |
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@alexcrichton I've updated the comment in |
Sorry I think more things need to be added here:
|
@alexcrichton Got it, I would check the 4th point tomorrow by looking into the std library. |
@alexcrichton I've checked the source code of However, the use of |
Since `Command` keeps pre exec function alive, we just need to pass in an `Arc` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@alexcrichton The test |
No I would prefer to not land a broken test that doesn't succeed on all platforms. |
Fair enough. After looking at the mod |
This comment was marked as outdated.
This comment was marked as outdated.
Ignore the previous comment, it was actually wrong. I mistook |
That takes any type that implements `Command` and a function `f` that spawns the process. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
By changing `{windows, wasm, unix}::Client::string_arg` to return `std::borrow::Cow<'_, str>` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
@alexcrichton I have fixed the CI failure, can you review this again please? The latest commits fixed this by changing
This also avoids the use of I also added support for |
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
Sorry this has grown to the point that I don't really know what's going on internally any more. If it's this difficult to fix the original issue then it may not be worth fixing or otherwise could try to just result in a better error or something like that. |
The original issue is caused by the API itself. The original API says that we can configure a Trying to clone and store Thus I decided to redesign the API to better illustrate that relationship and avoid the performance cost. In the new API, you have to spawn inside This works for |
Yes I understand it's the API itself that's causing the issue. This is so significantly different from before that I don't want to pull it into this crate. If you'd like though you could maintain a separate crate which depends on this one. |
Understandable, I might just fork this crate and create jobserver2. |
Fixed #25
Signed-off-by: Jiahao XU Jiahao_XU@outlook.com