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

Added unsafe SendSEXP to ownership-module #666

Merged
merged 9 commits into from Apr 20, 2024
Merged

Conversation

CGMossa
Copy link
Member

@CGMossa CGMossa commented Nov 5, 2023

Currently, the Ownership module converts all SEXP to usize (?), such that they become Send, so that the ownership module can be used from multiple threads.

  • Wrap SEXP in an explicit Send type. Accessing the pointer would require safety comments, as it can only be accessed through inner and set_inner.
  • No pointer conversion to usize and back.
  • Prototype for an eventual support for an unsafe SendRobj.

Background

This came up when looking at why tests started to fail sporadically. This isn't meant to fix anything in particular,
but it adds an explicit unsafe layer that is involved with what the ownership-module currently does. If we get rid of multithreaded support, we'd still provide users with something similar to this, or they would write something themselves, see #659 for discussion.

@sorhawell
Copy link
Contributor

sorhawell commented Nov 5, 2023

I'm not familiar with the ownership.rs module.

As I read this PR, it might be compiled down to the very same binary before and after.
I think the aim of this PR makes sense to not hide pointers in plain usize, whenever possible.

@CGMossa
Copy link
Member Author

CGMossa commented Feb 29, 2024

I'm not familiar with the ownership.rs module.

As I read this PR, it might be compiled down to the very same binary before and after. I think the aim of this PR makes sense to not hide pointers in plain usize, whenever possible.

Thanks for your comment. It is indeed my intention not to convert pointers to usize and back again. I can't find a reason why this is definitively bad, but it is unnecessary and the intent is unclear.

@CGMossa CGMossa marked this pull request as ready for review March 31, 2024 06:57
@CGMossa
Copy link
Member Author

CGMossa commented Mar 31, 2024

I've rebased and removed commented code.

@Ilia-Kosenkov
Copy link
Member

This looks scary

Error: Error: SET_STRING_ELT() can only be applied to a 'character vector', not a 'integer'
*** longjmp causes uninitialized stack frame ***: terminated

@CGMossa
Copy link
Member Author

CGMossa commented Mar 31, 2024

This looks scary

Error: Error: SET_STRING_ELT() can only be applied to a 'character vector', not a 'integer'
*** longjmp causes uninitialized stack frame ***: terminated

Indeed. It is caused by the multithreaded issues we've been having. Restarting CI, will give us a success, by the luck of the draw. We can discuss this particular issue in #674, or other places.

Copy link
Contributor

@JosiahParry JosiahParry left a comment

Choose a reason for hiding this comment

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

I tested this PR on {rsgeo} it builds just fine and works as anticipated.

R CMD check output:
image

Cargo.lock illustrating it is using this branch.

image

I feel confident in merging this. But since this is my first time getting familiar with the ownership module I'd like to ensure another set of eyes approve it. Would either @Ilia-Kosenkov or @sorhawell mind giving this another approval?

@JosiahParry
Copy link
Contributor

@Ilia-Kosenkov do you have some time this week to review this PR?

@Ilia-Kosenkov
Copy link
Member

I saw it, I will check it this weekend.

@CGMossa
Copy link
Member Author

CGMossa commented Apr 7, 2024

@Ilia-Kosenkov where is your comment on .entry? I still don't know what to do there :(

@Ilia-Kosenkov
Copy link
Member

Disregard my comment on.entry, I was too meticulous :)

@JosiahParry
Copy link
Contributor

All comments have been resolved, green checks abound. I'm going to merge! Thanks for your patience @CGMossa

@JosiahParry JosiahParry merged commit ce3197f into master Apr 20, 2024
15 checks passed
@CGMossa CGMossa deleted the refactor_ownership branch April 20, 2024 12:10
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.

None yet

4 participants