{"action":"created","issue":{"url":"https://api.github.com/repos/vberger/wayland-client-rs/issues/65","repository_url":"https://api.github.com/repos/vberger/wayland-client-rs","labels_url":"https://api.github.com/repos/vberger/wayland-client-rs/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/vberger/wayland-client-rs/issues/65/comments","events_url":"https://api.github.com/repos/vberger/wayland-client-rs/issues/65/events","html_url":"https://github.com/vberger/wayland-client-rs/issues/65","id":177562011,"number":65,"title":"Destructor handling and safety","user":{"login":"vberger","id":3009227,"avatar_url":"https://avatars.githubusercontent.com/u/3009227?v=3","gravatar_id":"","url":"https://api.github.com/users/vberger","html_url":"https://github.com/vberger","followers_url":"https://api.github.com/users/vberger/followers","following_url":"https://api.github.com/users/vberger/following{/other_user}","gists_url":"https://api.github.com/users/vberger/gists{/gist_id}","starred_url":"https://api.github.com/users/vberger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vberger/subscriptions","organizations_url":"https://api.github.com/users/vberger/orgs","repos_url":"https://api.github.com/users/vberger/repos","events_url":"https://api.github.com/users/vberger/events{/privacy}","received_events_url":"https://api.github.com/users/vberger/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/vberger/wayland-client-rs/labels/C-client","name":"C-client","color":"fbca04"},{"url":"https://api.github.com/repos/vberger/wayland-client-rs/labels/C-scanner","name":"C-scanner","color":"fbca04"},{"url":"https://api.github.com/repos/vberger/wayland-client-rs/labels/C-server","name":"C-server","color":"fbca04"},{"url":"https://api.github.com/repos/vberger/wayland-client-rs/labels/T-bug","name":"T-bug","color":"207de5"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2016-09-17T07:35:41Z","updated_at":"2016-09-22T18:42:19Z","closed_at":null,"body":"In the current code, there is a big safety hole around destructors:\r\n\r\nWayland Proxies/Resources objects do not have a `Drop` impl. The rationale behind this is that you don't need to keep them around if the reference provided to you in the handler methods is enough, this stays close to the design of the original C library.\r\n\r\nHowever, there *are* destructor events. So for now, once you've called a destructor method or received a destructor event, you *must not* use the object again, or it may completely mess up the internal state of the C library.\r\n\r\nThis is obviously *unsafe*, but without any unsafe keyword. But I can't find a way to handle this properly which isn't either very cumbersome for the user of the libs, or adds significant overhead.\r\n\r\nMy ideas for now:\r\n\r\n- Stay like this, and document properly that here are hidden unsafeties in the lib\r\n- Don't provide handles to proxy/resources to the user in the callback, but only an ID. They are responsible to keep everything alive, and finding in their collections the appropriate object given its ID to use it. This is still unsafe, because the user *must* destroy the objects when they receive a destructor event, (on the contrary, the current design destroys the C object automatically, but not the rust handle)\r\n- Automatically track liveness of the objects with a \"destroyed\" flag. This means this flag must be checked at each method call, involving at least two pointer indirection and an atomic read, I think."},"comment":{"url":"https://api.github.com/repos/vberger/wayland-client-rs/issues/comments/248991601","html_url":"https://github.com/vberger/wayland-client-rs/issues/65#issuecomment-248991601","issue_url":"https://api.github.com/repos/vberger/wayland-client-rs/issues/65","id":248991601,"user":{"login":"Timidger","id":3515754,"avatar_url":"https://avatars.githubusercontent.com/u/3515754?v=3","gravatar_id":"","url":"https://api.github.com/users/Timidger","html_url":"https://github.com/Timidger","followers_url":"https://api.github.com/users/Timidger/followers","following_url":"https://api.github.com/users/Timidger/following{/other_user}","gists_url":"https://api.github.com/users/Timidger/gists{/gist_id}","starred_url":"https://api.github.com/users/Timidger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Timidger/subscriptions","organizations_url":"https://api.github.com/users/Timidger/orgs","repos_url":"https://api.github.com/users/Timidger/repos","events_url":"https://api.github.com/users/Timidger/events{/privacy}","received_events_url":"https://api.github.com/users/Timidger/received_events","type":"User","site_admin":false},"created_at":"2016-09-22T18:42:19Z","updated_at":"2016-09-22T18:42:19Z","body":"Thank you, you were very clear. I was not aware of how wlc managed its resource (for up until now we had not needed to know that), but it is clear now that Way Cooler will need to work out a different solution where we either ditch wlc (difficult) or work around this e.g with our own ipc system instead of wayland_sys."}}
{"actor":{"display_login":"Timidger"}}