From owner-freebsd-hackers@freebsd.org Fri Apr 26 08:35:43 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CE93D158D31C for ; Fri, 26 Apr 2019 08:35:43 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [88.99.82.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 980238948F; Fri, 26 Apr 2019 08:35:42 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2016.home.selasky.org (unknown [176.74.212.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 69F52260240; Fri, 26 Apr 2019 10:35:35 +0200 (CEST) Subject: Re: buf(9) woes: when does bcopy do nothing at all? To: Alan Somers , FreeBSD Hackers References: From: Hans Petter Selasky Message-ID: <4af9e5dd-8346-69b5-f999-57821d846b94@selasky.org> Date: Fri, 26 Apr 2019 10:35:08 +0200 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 980238948F X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; spf=pass (mx1.freebsd.org: domain of hps@selasky.org designates 88.99.82.50 as permitted sender) smtp.mailfrom=hps@selasky.org X-Spamd-Result: default: False [-5.21 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+a:mail.turbocat.net]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; SUBJECT_ENDS_QUESTION(1.00)[]; DMARC_NA(0.00)[selasky.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE(-3.17)[ip: (-9.39), ipnet: 88.99.0.0/16(-4.71), asn: 24940(-1.72), country: DE(-0.01)]; TO_DN_ALL(0.00)[]; MX_GOOD(-0.01)[cached: mail.turbocat.net]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-0.74)[-0.738,0]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:88.99.0.0/16, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCVD_COUNT_TWO(0.00)[2] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Apr 2019 08:35:44 -0000 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@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >