Early Draft: Add parameter to check if files are mapped in processes not part of the recording.
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.
...
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?
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.
Rebased and removed the ugly lsof system call by manually iterating through /proc/.../maps. Command line option might need another name now.
Rebased and renamed the parameter from --lsof to --check-outside-mmaps.
Or is this something we want to activate generally?
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.
- 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.
- 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.