From owner-freebsd-hackers@FreeBSD.ORG Fri Apr 19 18:53:48 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 DF834806 for ; Fri, 19 Apr 2013 18:53:48 +0000 (UTC) (envelope-from carl.shapiro@gmail.com) Received: from mail-qe0-f45.google.com (mail-qe0-f45.google.com [209.85.128.45]) by mx1.freebsd.org (Postfix) with ESMTP id A547C16AB for ; Fri, 19 Apr 2013 18:53:48 +0000 (UTC) Received: by mail-qe0-f45.google.com with SMTP id 1so2904004qee.4 for ; Fri, 19 Apr 2013 11:53:42 -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=dLLa+ibREzH7kQujv/SkDCDSWb0RAWuezP8m2ZiCneY=; b=D+jtxA/LeNjUAx9b5IXzFxTjQLND0BzejwS95tOkACjM/dLwKd7P01ZHl5J+0/WOkB /7yMuz2+NQwQC6Pnzo7Cp3zFiHmLpytJIn4mN2V0JHC1P6sqQu11WS9tXJVZ8Ml+fZAZ 5awbnnySuWd9Eif0ZQMoYiIH5849FJoV3Fqz13YmBz630QVdfS580DhKtZ5/iWxC9HXW mhm0BxC+GsYhWhEIEwJZNwDjMI+GkFbyIsqZIdycIYictJZ8iFa3ikWxt5HsjkYwPwC9 RvMHkNEQyAu4TSoVf2Xt9fWOf5ySD3D14ni4tbIzo4lQq6ML4DA0RzVFFS8xoLuh3ZF9 ZUPA== X-Received: by 10.49.82.4 with SMTP id e4mr16938207qey.62.1366397622665; Fri, 19 Apr 2013 11:53:42 -0700 (PDT) MIME-Version: 1.0 Received: by 10.49.130.225 with HTTP; Fri, 19 Apr 2013 11:53:22 -0700 (PDT) In-Reply-To: <20130419124942.GA67273@kib.kiev.ua> References: <20130417082143.GW2930@kib.kiev.ua> <20130419124942.GA67273@kib.kiev.ua> From: Carl Shapiro Date: Fri, 19 Apr 2013 11:53:22 -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: Fri, 19 Apr 2013 18:53:48 -0000 On Fri, Apr 19, 2013 at 5:49 AM, Konstantin Belousov wrote: > It would be of some interest to see the evidence. > Certainly. Here is some of the debugging messages that I added to my application. The first line is a print statement that executes after the system call returns. (As an aside, we issue system calls directly and do not link against the C library.) The other 2 lines of interest are output from the dump of /proc/curproc/map that correspond to the status and rusage addresses. wait4 returned EFAULT, status is 0xc20021c0e8 rusage is 0xc2000eaf30 ... 0xc1ffff0000 0xc200100000 245 0 0xfffffe07cd9ebbc8 rw- 1 0 0x3000 COW NNC default - CH 1001 ... 0xc200200000 0xc200300000 250 0 0xfffffe0215e3ed98 rw- 1 0 0x3000 COW NNC default - CH 1001 I realize this might not be satisfying but I am happy to provide any other information you might be interested in. Is your code multithreaded ? > Yes. The test case is required to decide whether the bug is in the application > or in the OS. > To be clear, I do not have a strong reason to believe there bug is in FreeBSD. My original enquiry was solely into whether we were misusing MADV_FREE pages. However, the wait4 failure is very suspicious because the only two addresses written to are "out" parameters. > There is no difference in the access performed by copyout vs. access > caused > by the usermode write. > Thanks. > No, I cannot give an advice, I think we should first decide which code > to blame. > Well, I have a strong suspicion the problem is caused by my application for the reasons mentioned above. > BTW, you could try enabling sysctl machdep.uprintf_signal. This does not seem to be available in my kernel but I could patch this change... http://svnweb.freebsd.org/base/head/sys/amd64/amd64/trap.c?r1=239251&r2=239252& ...and it looks like I need to rebuild my kernel anyway to enable DTrace. > Oh, you did not > specified the architecture and version of the system. Sorry, here is what "uname -mv" says FreeBSD 9.1-RELEASE #0 r243825: Tue Dec 4 09:23:10 UTC 2012 root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64