From owner-freebsd-hackers@FreeBSD.ORG Sat Apr 20 15:32:18 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 178F2D08 for ; Sat, 20 Apr 2013 15:32:18 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) by mx1.freebsd.org (Postfix) with ESMTP id 671FC16B for ; Sat, 20 Apr 2013 15:32:17 +0000 (UTC) Received: from tom.home (kostik@localhost [127.0.0.1]) by kib.kiev.ua (8.14.6/8.14.6) with ESMTP id r3KFW871085758; Sat, 20 Apr 2013 18:32:08 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.8.2 kib.kiev.ua r3KFW871085758 Received: (from kostik@localhost) by tom.home (8.14.6/8.14.6/Submit) id r3KFW8m6085757; Sat, 20 Apr 2013 18:32:08 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 20 Apr 2013 18:32:08 +0300 From: Konstantin Belousov To: Carl Shapiro Subject: Re: MADV_FREE and wait4 EFAULT Message-ID: <20130420153208.GD67273@kib.kiev.ua> References: <20130417082143.GW2930@kib.kiev.ua> <20130419124942.GA67273@kib.kiev.ua> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pZs/OQEoSSbxGlYw" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on tom.home 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: Sat, 20 Apr 2013 15:32:18 -0000 --pZs/OQEoSSbxGlYw Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 19, 2013 at 11:53:22AM -0700, Carl Shapiro wrote: > On Fri, Apr 19, 2013 at 5:49 AM, Konstantin Belousov wrote: >=20 > > It would be of some interest to see the evidence. > > >=20 > 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 rusa= ge > addresses. >=20 > 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 >=20 > I realize this might not be satisfying but I am happy to provide any other > information you might be interested in. >=20 > Is your code multithreaded ? > > >=20 > Yes. Just observations/speculations: the addresses you shown are not the (usual) addresses for the malloc heap on amd64. It is possible to allocate and map enough shared libraries to make malloc start using these addresses, but more likely your app is using custom mmap() calls, possibly with the explicite address hints or MAP_FIXED. Am I right ? If yes and your app is multithreaded, it is possible that other thread performs some manipulations on the address space while current thread tries to access the range. >=20 > The test case is required to decide whether the bug is in the application > > or in the OS. > > >=20 > 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 t= he > only two addresses written to are "out" parameters. In fact, the question is, why are you trying to access the memory after the MADV_FREE. Was it correctly marked as 'still used' to prevent mmaps there ? Note that all this is pure speculation. --pZs/OQEoSSbxGlYw Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iQIcBAEBAgAGBQJRcrT3AAoJEJDCuSvBvK1B5noQAJXqtOP+Q7pavJEYcovI8dxp T9hwMEeu26AbMg1tC498o5lWFc4oO0evwbgTNje+f3Rn7DkRBClr1cDFmTi/Y594 Nzip21ywYCG9IYZJ/NI7txzQ7grFdSaaLh0NnC7a/7ctpXY2wKRO46DOAsEHxnkN RurnfgScIxwPXW7jWxAUapVZKmwxbThe3+v03it7GmVoMDqtSCtW+3d+RsyP9a3o QuY2XymUh2sqmpXsCNUP3qvu/RWfSQfhaTbyaMzyUOl9rGpPe4a20oSvxHbVkkgQ CtonV+A0j21nal1mx5gPiXPVwMQNBh2sb1QEeI4HJoQ/bdnfb9iq/WnoLDyfXYUg 6eD/9b3pp0vthoaIPgcb4fbDenRWNkjbRyrjYHrLl6fFM3X7TT0A2sLEPWogr6sO bXJHBNCP+Jd96dyHw0pJS396KPZIZ0zeo0lAIEzB2la8734q0kMXWf4Fb0/be80u OOmY7urPIo19FVHULFZhx8zPL5t5WcOiyHJCAYxk6vPs+QgOv3XcWdFjJzDm8X1T tSxDASPLLUohPWNzwItXg0+ri2kHs/hlfg2ejfOtNKsAb5xwyukf5IeyB51h5ryc u2Q0WJlJ/IlT+e0ZCjLdPnjXGACDU+HydhWnDXJvQV4uBApKErRw0qGewJaf/nFc u8aX6u6apcjQlHivYqDB =enUq -----END PGP SIGNATURE----- --pZs/OQEoSSbxGlYw--