-
Notifications
You must be signed in to change notification settings - Fork 815
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 a cleanup step that will mark all the memory as inaccessible and thus force termination of threads #3688
base: main
Are you sure you want to change the base?
Changes from all commits
88eb597
e2cb8d6
7e0fc8f
d13b6d3
1148595
e92d719
e0ac375
89292fe
a8f2e19
a8f5a2b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -233,6 +233,28 @@ impl Mmap { | |
Ok(()) | ||
} | ||
|
||
/// Make the entire memory inaccessible to both reads and writes. | ||
pub fn make_all_inaccessible(&self) -> Result<(), String> { | ||
self.make_inaccessible(0, self.total_size) | ||
} | ||
|
||
/// Make the memory starting at `start` and extending for `len` bytes inaccessible | ||
/// to both reads and writes. | ||
/// `start` and `len` must be native page-size multiples and describe a range within | ||
/// `self`'s reserved memory. | ||
pub fn make_inaccessible(&self, start: usize, len: usize) -> Result<(), String> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably keep the additional API surface we expose minimal, so we can change/remove it again without a breaking change. Wouldn't exposing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah that's true - i can make this change and hide some of the API internals |
||
let page_size = region::page::size(); | ||
assert_eq!(start & (page_size - 1), 0); | ||
assert_eq!(len & (page_size - 1), 0); | ||
assert_le!(len, self.total_size); | ||
assert_le!(start, self.total_size - len); | ||
|
||
// Commit the accessible size. | ||
let ptr = self.ptr as *const u8; | ||
unsafe { region::protect(ptr.add(start), len, region::Protection::NONE) } | ||
.map_err(|e| e.to_string()) | ||
} | ||
|
||
/// Return the allocated memory as a slice of u8. | ||
pub fn as_slice(&self) -> &[u8] { | ||
unsafe { slice::from_raw_parts(self.ptr as *const u8, self.total_size) } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This enum does not have
non_exhaustive
, so adding a new variant is a breaking change. We can't do this quite yet.I suggest:
Generic
variant4.0
milestone to track adding a new variantcleanup()
codeThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand why you would mention
non_exhaustive
enums but this change in the upcoming beta does not sound like a big issue to me considering all the other breaking changes that are going into that release - either way I would rather go back to the way I had it returningOk(())
if we are not going to do it properly - this small part of the change already cost too much time.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is this is in the core Wasmer types, not in WASI.
There currently is no breaking change planned for Wasmer immediately, only later down the line.
So the next release will be
3.2
, a non-breaking change.