]> git.ipfire.org Git - thirdparty/valgrind.git/commit
Bug 452274 memcheck crashes with Assertion 'sci->status.what == SsIdle' failed
authorPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 12 Apr 2022 21:34:41 +0000 (23:34 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Tue, 12 Apr 2022 21:50:48 +0000 (23:50 +0200)
commit3e7774ea5a5eda11d37bc4670aad8a3cb8a260fe
treeabe58218f403001b657691ae31ba04c2ae2639e8
parent68ac5ca0ea91e0591c94083486ffd77ef112b447
Bug 452274 memcheck crashes with Assertion 'sci->status.what == SsIdle' failed

FreeBSD (and Darwin) use the carry flag for syscall syscall status.
That means that in the assembler for do_syscall_for_client_WRK
they have a call to LibVEX_GuestAMD64_put_rflag_c (amd64) or
LibVEX_GuestX86_put_eflag_c (x86). These also call WRK functions.

The problem is that do_syscall_for_client_WRK has carefully crafted
labels correspinding to IP addresses. If a signal interrupts
processdings, IP can be compared to these addresses so that
VG_(fixup_guest_state_after_syscall_interrupted) can work
out how to resume the syscall. But if IP is in the save
carry flag functions, the address is not recognized and
VG_(fixup_guest_state_after_syscall_interrupted) fails.

The crash in the title happens because the interrupted
syscall does not reset its status, and on the next syscall
it is expected that the status be idle.

To fix this I added global variables that get set to 1
just before calling the save carry flag functions, and cleared
just after. VG_(fixup_guest_state_after_syscall_interrupted)
can then check this and work out which section we are in
and resume the syscall correctly.

Also:

Start a new NEWS section for 3.20

Add a regtest for this and also a similar one for Bug 445032
(x86-freebsd only, new subdir).

I saw that this problem also probably exists with macOS, so I made
the same changes there (not yet tested)
19 files changed:
.gitignore
NEWS
configure.ac
coregrind/m_syswrap/syscall-amd64-darwin.S
coregrind/m_syswrap/syscall-amd64-freebsd.S
coregrind/m_syswrap/syscall-x86-darwin.S
coregrind/m_syswrap/syscall-x86-freebsd.S
coregrind/m_syswrap/syswrap-main.c
none/tests/Makefile.am
none/tests/freebsd/452275.c [new file with mode: 0644]
none/tests/freebsd/452275.stderr.exp [new file with mode: 0644]
none/tests/freebsd/452275.vgtest [new file with mode: 0644]
none/tests/freebsd/Makefile.am
none/tests/freebsd/filter_452275 [new file with mode: 0755]
none/tests/x86-freebsd/445032.c [new file with mode: 0644]
none/tests/x86-freebsd/445032.stderr.exp [new file with mode: 0644]
none/tests/x86-freebsd/445032.vgtest [new file with mode: 0644]
none/tests/x86-freebsd/Makefile.am [new file with mode: 0644]
none/tests/x86-freebsd/filter_stderr [new file with mode: 0755]