Skip to content

Skip some tests if run with 32-bit rr under a 64-bit kernel - #2784

Merged
rocallahan merged 4 commits into
rr-debugger:masterfrom
bernhardu:skip-32-with-64-kernel
Jan 13, 2021
Merged

rocallahan merged 4 commits into
rr-debugger:masterfrom
bernhardu:skip-32-with-64-kernel

Conversation

@bernhardu

Copy link
Copy Markdown
Contributor

This is mostly done by detecting bitness or the name of librrpage.so.
Can we take a which and file in the environment as given?
In 64bit_child.c the following comment makes me wonder if it is still true:

  /* Fork-and-exec 'echo'.
     The exec may fail if 'bash' is 64-bit and rr doesn't support
     64-bit processes. That's fine; the test should still pass. We're
     testing that rr doesn't abort.
   */

In my tests a 32-bit rr with a 64-bit shell under a 64-bit kernel, if not skipped, does abort like this:

$ bin/rr record bin/64bit_child
rr: Saving execution to trace directory `/home/bernhard/.local/share/rr/64bit_child-0'.
rr: /home/bernhard/data/entwicklung/2020/rr/2021-01-03/rr/src/Registers.cc:550: void rr::Registers::set_from_ptrace(const rr::X86Arch::user_regs_struct&): Assertion `arch() == x86 && NativeArch::arch() == x86_64' failed.
Aborted (core dumped)

Therefore should this comment be removed too?

Related to #2782

@rocallahan

Copy link
Copy Markdown
Collaborator

Therefore should this comment be removed too?

I'm not sure what to do when someone tries to exec a 64-bit binary under 32-bit rr, but hitting that DEBUG_ASSERT is probably not the right thing to do (for one thing, it will behave differently in release builds). I think we should probably have an explicit check somewhere in the exec code and either cause rr to die with FATAL(), or cause the execve syscall to fail.

@Keno

Keno commented Jan 5, 2021

Copy link
Copy Markdown
Member

I think we should probably have an explicit check somewhere in the exec code and either cause rr to die with FATAL(), or cause the execve syscall to fail.

My preference would be to fail the execve with ENOEXEC:

       ENOEXEC
              An executable is not in a recognized format, is for the
              wrong architecture, or has some other format error that
              means it cannot be executed.

which is what would happen if you tried to exec an incorrect architecture executable. With 32bit rr we're essentially a 32bit kernel, so that seems like the right thing to do.

@bernhardu

Copy link
Copy Markdown
Contributor Author

Thank you all for your input, but I fear I am not able to find a location where I can intercept the exec syscall.
Additionally I am not sure how or where to detect that the exec is about a x86_64 image.
(E.g. when a script is executed via a shebang)

As far as I see rr recognizes the architecture first in
Task::did_waitpid with SupportedArch a = is_long_mode_segment(registers.cs()) ? x86_64 : x86;.
But I don't know how to get the execve to fail from there, if it is there still possible.
At that time we went already through Scheduler::did_enter_execve but have not yet reached Scheduler::did_exit_execve.

Is something similar done already somewhere else?

@rocallahan

Copy link
Copy Markdown
Collaborator

That's a good question. It's probably not worth trying to predict what the kernel will end up execing so we can test it. Let's just fail with a FATAL() instead.

@bernhardu
bernhardu force-pushed the skip-32-with-64-kernel branch from 72e5b56 to 87f268a Compare January 12, 2021 22:32
@bernhardu

Copy link
Copy Markdown
Contributor Author

I hope it is ok to just add that FATAL to the place where rr first detects that we have a x86_64 process instead of changing the DEBUG_ASSERT?

Comment thread src/test/util.sh Outdated
if [[ "_32" == $bitness ]] || [[ "$(uname -m)" =~ i[3-6]86 ]]; then
if [[ "_32" == $bitness ]] ||
[[ "$(uname -m)" =~ i[3-6]86 ]] ||
[[ "$(file $RESOURCE_PATH/lib/rr/librrpage.so | grep 32-bit -c)" == "1" ]];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think we need to split skip_if_32_bit into two functions:

-- One that aborts the test if it's a 32-bit test. Let's say skip_if_test_32_bit

-- One that aborts the test if this is a 32-bit rr build. Let's say skip_if_rr_32_bit.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't think we need to check uname and librrpage.so. Just checking librrpage.so is a good way to detect 32-bit rr.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have split skip_if_32_bit into two, dropped the uname, and added skip_if_rr_32_bit to the just failing two tests.

@bernhardu
bernhardu force-pushed the skip-32-with-64-kernel branch from 87f268a to 4c2b16f Compare January 13, 2021 11:02
@rocallahan
rocallahan merged commit 314dae2 into rr-debugger:master Jan 13, 2021
@bernhardu
bernhardu deleted the skip-32-with-64-kernel branch March 20, 2024 09:23
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