i386 memory fence incompatible with valgrind

Matthias Urlichs matthias at urlichs.de
Sun Jan 15 18:55:12 CET 2017

On 15.01.2017 15:47, Marc Lehmann wrote:
> The kernel
> allocates pages depending on the address thats faulting, it will not
> disassemble the instruction and see how the address was calculated.
You might want to refer you to arch/x86/mm/fault.c in the kernel.

                 * Accessing the stack below %sp is always a bug.

You can't get more assertive than that.

Your assertion that the kernel doesn't check opcodes is incorrect; see
check_prefetch_opcode() starting at line 93 in the same file for one
example. It doesn't currently do that for below-the-stack accesses
(which it'd have to do, because the kernel fault handler sees the
not-decremented value of the stack pointer – my mistake, as that's only
visible to the kernel fault handler but not to a checker like valgrind),
but nothing prevents it from doing so.

> and the problem in valgrind has nothing to do with the fact that the
> access is below the stack pointer at the time.

why not? that's precisely what it checks for.

Replacing -1 with 0 in one macro is not a "hack". It's replacing an
arbitrary value which triggers a warning, with another and arguably
somewhat-less-arbitrary value which does not.

I also fail see where you get the "layers of hacks upon hacks" idea from.

WRT discussion style: your mistake is, well, a simple mistake, but mine
are "bullshit" and "pulling something out of my ass"? Come on.

-- Matthias Urlichs

More information about the libev mailing list