Hi all,

I'm trying to decide if a valgrind warning is a false positive or not.

The code comes from libev's memory fence implementation and reduces to:

-------------------------------------
#include <stdio.h>

int main (void)
{
#if __i386 || __i386__

        printf ("hello 32 bit world \n");
        __asm__ __volatile__ ("lock; orb $0, -1(%%esp)" : : : "memory");
        printf ("goodbye 32 bit world \n");

#endif

        return 0;
}
-------------------------------------

valgrind 3.9.0 complains (on linux, in i386 only of course):

"Invalid read of size 1"
"Address 0x4f760ff is just below the stack ptr."

The libev author believes it is a false positive from valgrind:

<http://lists.schmorp.de/pipermail/libev/2013q2/002173.html>

I've searched the valgrind bug list, but can't seem to find anything related.  
I don't really know Intel assembly, but I guess that's doing an OR of constant 
zero and one byte away from the stack pointer.  Seems dubious to me.

Anyone have thoughts on the snippet's correctness?  Is valgrind indeed wrong to 
complain?

Thanks,

-- 
____________________________________________________________
Sean McBride, B. Eng                 s...@rogue-research.com
Rogue Research                        www.rogue-research.com 
Mac Software Developer              Montréal, Québec, Canada



------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121051231&iu=/4140/ostg.clktrk
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to