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

Session::recreate_shared_mmap fixes #3863

Merged
merged 1 commit into from
Nov 3, 2024

Conversation

sidkshatriya
Copy link
Contributor

@sidkshatriya sidkshatriya commented Oct 28, 2024

While unmapping a Mapping local_addr, take into account that the Mapping m passed in as a method parameter may come from a Task that differs from the remote.task() so the Mapping at m.map.start() for remote.task() may be different to m.

@sidkshatriya
Copy link
Contributor Author

(I think my fix is correct -- however do think if there could be some scenarios where my ASSERTs for instance would not hold etc.)

@@ -300,6 +300,8 @@ template <typename Arch> static void prepare_clone(ReplayTask* t) {
new_task->vm()->remove_all_watchpoints();

AutoRemoteSyscalls remote(new_task);
// Note that iteration is on Task `t` while any syscalls
// via `remote` will be issued on Task `new_task`
for (const auto& m : t->vm()->maps()) {
Copy link
Contributor Author

@sidkshatriya sidkshatriya Oct 28, 2024

Choose a reason for hiding this comment

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

This loop is essentially the culprit for the fix in this PR

@@ -575,9 +585,16 @@ const AddressSpace::Mapping Session::recreate_shared_mmap(
new_map = remote.task()->vm()->mapping_of(new_addr);
if (preserved_data) {
memcpy(new_map.local_addr, preserved_data, size);
munmap(preserved_data, size);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This here is very problematic as it could unmap the local memory for the wrong task. We want to unmap for remote.task()Mapping's local_addr and not for Mapping m's local_addr

Copy link
Collaborator

@rocallahan rocallahan left a comment

Choose a reason for hiding this comment

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

Basically looks good but I think it needs some cleanup.

src/Session.cc Outdated Show resolved Hide resolved
src/Session.cc Outdated Show resolved Hide resolved
src/Session.cc Outdated Show resolved Hide resolved
src/replay_syscall.cc Outdated Show resolved Hide resolved
While unmapping a Mapping local_addr, take into account
that the Mapping `m` passed in as a method parameter may
come from a Task that differs from the remote.task() so
the Mapping at m.map.start() for remote.task() may be
different to `m`.
@sidkshatriya
Copy link
Contributor Author

The build failure on aarch64 is due to something unrelated. See #3865 (comment)

@sidkshatriya
Copy link
Contributor Author

sidkshatriya commented Nov 2, 2024

Done -- ready for further review/merge.


There is a single failure in x86_64 136 - doublesegv-no-syscallbuf (Failed) -- not sure why it failed -- it had passed in the initial version of this PR. There is a test timeout of 120 seconds.

And then rr itself crashes due to SIGSEGV (see test transcript).

@rocallahan rocallahan merged commit 5472a2f into rr-debugger:master Nov 3, 2024
3 of 5 checks passed
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.

2 participants