From owner-cvs-src-old@FreeBSD.ORG Wed Nov 3 09:23:24 2010 Return-Path: Delivered-To: cvs-src-old@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B626D106564A for ; Wed, 3 Nov 2010 09:23:24 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id A39A18FC08 for ; Wed, 3 Nov 2010 09:23:24 +0000 (UTC) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.4/8.14.4) with ESMTP id oA39NONL017578 for ; Wed, 3 Nov 2010 09:23:24 GMT (envelope-from kib@repoman.freebsd.org) Received: (from svn2cvs@localhost) by repoman.freebsd.org (8.14.4/8.14.4/Submit) id oA39NO3D017577 for cvs-src-old@freebsd.org; Wed, 3 Nov 2010 09:23:24 GMT (envelope-from kib@repoman.freebsd.org) Message-Id: <201011030923.oA39NO3D017577@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: svn2cvs set sender to kib@repoman.freebsd.org using -f From: Konstantin Belousov Date: Wed, 3 Nov 2010 09:23:08 +0000 (UTC) To: cvs-src-old@freebsd.org X-FreeBSD-CVS-Branch: HEAD Subject: cvs commit: src/libexec/rtld-elf rtld.c rtld.h X-BeenThere: cvs-src-old@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: **OBSOLETE** CVS commit messages for the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Nov 2010 09:23:24 -0000 kib 2010-11-03 09:23:08 UTC FreeBSD src repository Modified files: libexec/rtld-elf rtld.c rtld.h Log: SVN rev 214728 on 2010-11-03 09:23:08Z by kib If dlopen() is called for the dso that has been already loaded as a dependency, then the dso never has its DAG initialized. Empty DAG makes ref_dag() call in dlopen() a nop, and the dso refcount is off by one. Initialize the DAG on the first dlopen() call, using a boolean flag to prevent double initialization. From the PR (edited): Assume we have a library liba.so, containing a function a(), and a library libb.so, containing function b(). liba.so needs functionality from libb.so, so liba.so links in libb.so. An application doesn't know about the relation between these libraries, but needs to call a() and b(). It dlopen()s liba.so and obtains a pointer to a(), then it dlopen()s libb.so and obtains a pointer to b(). As soon as the application doesn't need a() anymore, it dlclose()s liba.so. Expected result: the pointer to b() is still valid and can be called Actual result: the pointer to b() has become invalid, even though the application did not dlclose() the handle to libb.so. On calling b(), the application crashes with a segmentation fault. PR: misc/151861 Based on patch by: jh Reviewed by: kan Tested by: Arjan van Leeuwen MFC after: 1 week Revision Changes Path 1.158 +13 -2 src/libexec/rtld-elf/rtld.c 1.47 +1 -0 src/libexec/rtld-elf/rtld.h