buf(9) woes: when does bcopy do nothing at all?

Hans Petter Selasky hps at selasky.org
Fri Apr 26 08:35:44 UTC 2019


On 4/26/19 5:31 AM, Alan Somers wrote:
> How is it possible that bcopy() doesn't affect its output array at
> all?  While investigating a data corruption issue in fuse, I narrowed
> the problem down to a bcopy operation that apparently has no affect.
> The code in question is:
> 

Hi,

Can you show the whole code? Which architecture is this?

Can you also print all arguments when this happens?

--HPS

> bcopy(cp, iov->iov_base, cnt);
> r = memcmp(cp, iov->iov_base, cnt);
> if (r)
>      printf("uiomove: miscompare\n");
> 
> Rationally, I would expect that line never to be printed.  But it
> does.  The destination is always all zeros, even though the source is
> not.  I can only guess that there's something wrong about the way that
> I I'm using buf(9), because the output is part of a buffer allocated
> by bread(9).  I've been able to rule out:
> 
> 1) Race conditions.  The bug is 100% reproducible, and doubling the
> bcopy or changing the timing in other ways has no effect.
> 2) Unmapped buffer.  I verified that the buf is not unmapped_buf.
> 3) Overlapping src and dst
> 4) Duplicated pages.  I verified that each of the buf's pages has a
> unique physical address
> 5) Bad RAM.  My machine passes memtest86, and anyway the failure is
> too specific and reproducible to be caused by bad hardware.
> 
> What could I be missing?  Do I need to do something to prepare the buf
> before I can use it?  The code that allocates the buffer is here:
> https://svnweb.freebsd.org/base/projects/fuse2/sys/fs/fuse/fuse_io.c?view=markup#l240
> 
> -Alan
> _______________________________________________
> freebsd-hackers at freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> To unsubscribe, send any mail to "freebsd-hackers-unsubscribe at freebsd.org"
> 



More information about the freebsd-hackers mailing list