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

Add parameter to check if files are mapped in processes not part of the recording. #3419

Merged
merged 1 commit into from
Sep 26, 2024

Conversation

bernhardu
Copy link
Contributor

In its current state it just calls lsof with the pids inside the the recording excluded.

It would show the mapping that caused the issue in #3417,
but the others are probably just read-only mappings due to /proc/pid/maps.

$ rr record --lsof -n atril sshfs/home/benutzer/test2.pdfrr: Saving execution to trace directory `/home/bernhard/data/entwicklung/2022/rr/rr-recordings/atril-14'.
Warning: /usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache seems to be mapped by a process outside of the recording. Diversions might happen when replaying this trace.
Warning: /home/bernhard/.cache/fontconfig/a6050266-6adb-4e1c-8a1d-f55d18a3f9c3-le64.cache-7 seems to be mapped by a process outside of the recording. Diversions might happen when replaying this trace.
Warning: /run/user/1000/dconf/user seems to be mapped by a process outside of the recording. Diversions might happen when replaying this trace.
Warning: /home/bernhard/.local/share/mime/mime.cache seems to be mapped by a process outside of the recording. Diversions might happen when replaying this trace.
Warning: /usr/local/share/mime/mime.cache seems to be mapped by a process outside of the recording. Diversions might happen when replaying this trace.
Warning: /usr/share/mime/mime.cache seems to be mapped by a process outside of the recording. Diversions might happen when replaying this trace.
Warning: /home/bernhard/.local/share/gvfs-metadata/root seems to be mapped by a process outside of the recording. Diversions might happen when replaying this trace.
Warning: /home/bernhard/.local/share/gvfs-metadata/root-5c301c7a.log seems to be mapped by a process outside of the recording. Diversions might happen when replaying this trace.
...

@bernhardu
Copy link
Contributor Author

bernhardu commented Feb 15, 2023

The call to system() might be ugly to dangerous. lsof seems to want in the long term to make it available as library.
Would the license allow it?

@rocallahan
Copy link
Collaborator

This would be a cool feature to have but rather than calling lsof I think we would want to reimplement the functionality by scanning /proc/.../maps.

@bernhardu bernhardu force-pushed the check-outside-mappings branch 2 times, most recently from f8cc6dd to 589b266 Compare September 9, 2024 20:07
@bernhardu
Copy link
Contributor Author

Rebased and removed the ugly lsof system call by manually iterating through /proc/.../maps.
Command line option might need another name now.

@bernhardu bernhardu force-pushed the check-outside-mappings branch 2 times, most recently from c1dab11 to 60d34c1 Compare September 23, 2024 12:35
@bernhardu bernhardu marked this pull request as ready for review September 23, 2024 12:39
@bernhardu
Copy link
Contributor Author

Rebased and renamed the parameter from --lsof to --check-outside-mmaps.

Or is this something we want to activate generally?

@bernhardu bernhardu changed the title Early Draft: Add parameter to check if files are mapped in processes not part of the recording. Add parameter to check if files are mapped in processes not part of the recording. Sep 23, 2024
@bernhardu bernhardu force-pushed the check-outside-mappings branch from 60d34c1 to 559a4f2 Compare September 23, 2024 14:31
@bernhardu
Copy link
Contributor Author

Small addition, return after first process is found with outside mapping and message got printed.

Global activation would succeed with the test suite except test mmap_self_maps_shared.

@bernhardu bernhardu force-pushed the check-outside-mappings branch from 559a4f2 to d36beb9 Compare September 25, 2024 14:12
@bernhardu
Copy link
Contributor Author

  • Replaced the system function call by fork+execve.
  • Add timeout to the test executable, to avoid it runs forever.

I made some tests to activate it generally.
This would at least not work for 32-bit rr running at a 64-bit kernel, because the KernelMapIterator does not like higher bitnesses than it being compiled for.
Also the mmap_self_maps_shared test would trigger for files libc.so.6, libdl.so.2, ld-linux-x86-64.so.2, if used generally.

src/record_syscall.cc Outdated Show resolved Hide resolved
src/record_syscall.cc Outdated Show resolved Hide resolved
src/record_syscall.cc Outdated Show resolved Hide resolved
@bernhardu bernhardu force-pushed the check-outside-mappings branch from d36beb9 to fa6ab22 Compare September 26, 2024 12:15
@bernhardu
Copy link
Contributor Author

  • Skip test when running a force32bit build on a 64-bit system.
  • Add fatal message when running a force32bit build on a 64-bit system.
  • Simplify by using Session::find_task.
  • Fixed break, which left the check when the first traced process was reached.
  • Change comparison from filename to device and inode.

@rocallahan rocallahan merged commit 1db6339 into rr-debugger:master Sep 26, 2024
5 checks passed
@bernhardu bernhardu deleted the check-outside-mappings branch September 27, 2024 09:45
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