Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Lichtso
Copy link
Collaborator

@Lichtso Lichtso commented Apr 15, 2025

  • MemoryCowCallback is always Some() in production, thus remove the Option<>.
  • Reorders the additional cow_cb parameter to be last in new_with_cow constructors for consistency with the new constructors.
  • Makes cow_callback_payload independent of the MemoryState. This will later allow writable regions to be identifiable inside the MemoryCowCallback as well.
  • Replaces MemoryState by boolean flag writable.
  • Reduces cow_callback_payload from u64 to u32.

@Lichtso Lichtso force-pushed the refactor/simplify_cow branch 2 times, most recently from 6da3754 to cceb6ba Compare April 15, 2025 14:23
@Lichtso Lichtso force-pushed the refactor/simplify_cow branch from cceb6ba to 5feb4c3 Compare April 15, 2025 14:35
@Lichtso Lichtso requested a review from LucasSte April 15, 2025 14:50
Comment on lines 36 to 40
pub type AccessViolationHandler = Box<dyn Fn(u32) -> Result<u64, ()>>;
/// Fail always
#[allow(clippy::result_unit_err)]
pub fn default_access_violation_handler(_: u32) -> Result<u64, ()> {
Err(())
Copy link
Collaborator

Choose a reason for hiding this comment

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

The usage of the function is to try to write to the memory and copy if it is readonly, right? I believe the old name MemoryCowCallback (or something related) is clearer on the intentions of this function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can split the renaming into a separate PR. But in the future it is not only for CoW (readonly to writable) but also to map in unmapped address space (for growing the realloc padding).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, another PR is good.

but also to map in unmapped address space

MemoryCowCallback isn't the best option considering that, but I still prefer it to describe what the function does, instead of the error it might return when it can't do what it is supposed to.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well the naming scheme is similar to the signal segmentation fault (SIGSEGV) signal handler. That one is also named after the signal / error message.

@Lichtso Lichtso force-pushed the refactor/simplify_cow branch from 5feb4c3 to 1b8335b Compare April 15, 2025 20:32
@Lichtso Lichtso requested a review from LucasSte April 15, 2025 20:33
@Lichtso Lichtso force-pushed the refactor/simplify_cow branch from 1b8335b to 6920d29 Compare April 15, 2025 20:35
@Lichtso Lichtso merged commit 6defa69 into main Apr 15, 2025
11 checks passed
@Lichtso Lichtso deleted the refactor/simplify_cow branch April 15, 2025 20:52
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.

3 participants