From owner-freebsd-hackers@FreeBSD.ORG Thu Apr 18 21:52:04 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 458FFCE0 for ; Thu, 18 Apr 2013 21:52:04 +0000 (UTC) (envelope-from carl.shapiro@gmail.com) Received: from mail-qc0-x235.google.com (mail-qc0-x235.google.com [IPv6:2607:f8b0:400d:c01::235]) by mx1.freebsd.org (Postfix) with ESMTP id 0D0B53FA for ; Thu, 18 Apr 2013 21:52:03 +0000 (UTC) Received: by mail-qc0-f181.google.com with SMTP id a22so1663152qcs.12 for ; Thu, 18 Apr 2013 14:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=Y/URqVT4dYtrahLFRfGnVAS8kXWH8yKlHvr+C/PjVZE=; b=dJ2FiNe1nrFXd52SU0sVqQwxEWmab3s3mulmZPJLNLhWMJCUP5C5acAPwYdJY1/QD3 SHCo+RpqFm7Wg3geUVozZ1bl2B82Vgxuhgr/LuuAGTe9cFLk0WQk6CMKnMrb5l0pWmX1 tt7cB9kQATRlYcmfwph4DYp5J/ZgNmfzT09BFfIPEpxLk3gSPtBxRFYScU7QytXgsBWV hLKSTjdkJKYQ6tqNmD4rh4R+8ZMwctRC23EZHe/UOSbGdFCl/b7aT81gaQc0BbidYOng MwbNEunvTUw+I2czd12Mv+S6vJeKCDXPynOWbJuRvoQ6pxbC+O/pPg95uODMz5NXkt2c gLPw== X-Received: by 10.229.0.141 with SMTP id 13mr682425qcb.80.1366321923633; Thu, 18 Apr 2013 14:52:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.49.130.225 with HTTP; Thu, 18 Apr 2013 14:51:43 -0700 (PDT) In-Reply-To: <20130417082143.GW2930@kib.kiev.ua> References: <20130417082143.GW2930@kib.kiev.ua> From: Carl Shapiro Date: Thu, 18 Apr 2013 14:51:43 -0700 Message-ID: Subject: Re: MADV_FREE and wait4 EFAULT To: Konstantin Belousov Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: FreeBSD Hackers X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 18 Apr 2013 21:52:04 -0000 On Wed, Apr 17, 2013 at 1:21 AM, Konstantin Belousov wrote: > Did you ensured with e.g. ktrace and procstat -v that your assumptions > hold, i.e. the addresses supplied as wait4(2) arguments are valid ? > Please provide the minimal test case demonstrating the behaviour. > Yes. I instrumented my code to check for a wait4 failure, print the addresses of the status and rusage arguments, and dump the contents of /proc/curproc/map. The addresses of the status and rusage arguments are always in the range of a mapping and marked as read write. I have yet to distill the failure to a minimal test case. The test case I do have is the test harness for the Go language. After running for about 45 minutes I can observe a failure. I have been working to produce something smaller and faster. > MADV_FREE should only result in the possible lost of the previous > content of the page, not in the faulting of the page access. From the > inspection of the code, I do not see how MADV_FREE could result in > the memory address becoming invalid. > I see. What has lead us to believe this might be an issue with page faults is that writing zeroes to the page with memset before passing it to wait4 makes the error go away. Do you have any advice about how one might go about instrumenting wait4 to generate more information about a failed copyout? Are tools such as dtrace useful in these situations or might it be too invasive? Because of the protracted test cycle and my lack of knowledge in this area, conducting experiments is quite painful at the moment. Thanks, Carl