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

Ownership.own does not check if the resource is already owned #30

Open
polytypic opened this issue Jul 21, 2024 · 1 comment
Open

Ownership.own does not check if the resource is already owned #30

polytypic opened this issue Jul 21, 2024 · 1 comment
Assignees

Comments

@polytypic
Copy link
Contributor

I noticed recently that Ownership.own:

miou/lib/miou.ml

Lines 985 to 993 in 072de4f

let own (Resource { uid; _ } as res) =
let (Pack self) = Effect.perform Self in
Logs.debug (fun m ->
m "[%a] adds [%a] into %a" Domain_uid.pp self.runner Resource_uid.pp uid
Promise.pp self);
let equal (Resource { uid= uid'; _ }) = Resource_uid.equal uid uid' in
if Miou_sequence.exists equal self.resources then
invalid_arg "The current promise already holds the resource given"
else Miou_sequence.(add Left) self.resources res

does not check whether the resource is already owned by some other fiber (or promise). Currently, if you call Ownership.own on a resource that is already owned by some other fiber, then it will corrupt the resource list of that other fiber.

@dinosaure
Copy link
Contributor

This is more in line with the Rust-style exclusion model you might have in mind when manipulating resources. I'll try to find a solution here. The Ownership API is still experimental and I'll have to iterate on it to see if it works. Thanks.

@dinosaure dinosaure self-assigned this Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants