From owner-svn-src-head@freebsd.org Fri Jun 30 20:27:53 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 05F2ED9A01F; Fri, 30 Jun 2017 20:27:53 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (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 C89047BD97; Fri, 30 Jun 2017 20:27:52 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5UKRqNk001262; Fri, 30 Jun 2017 20:27:52 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5UKRpeQ001259; Fri, 30 Jun 2017 20:27:51 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201706302027.v5UKRpeQ001259@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 30 Jun 2017 20:27:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r320509 - in head/lib/libc: include stdio X-SVN-Group: head X-SVN-Commit-Author: kib X-SVN-Commit-Paths: in head/lib/libc: include stdio X-SVN-Commit-Revision: 320509 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Jun 2017 20:27:53 -0000 Author: kib Date: Fri Jun 30 20:27:51 2017 New Revision: 320509 URL: https://svnweb.freebsd.org/changeset/base/320509 Log: In the stdio cleanup push and pop wrappers, always call libc stubs for __pthread_cleanup_push/pop_imp instead of symbols also exported from libthr. This prevents calls into libthr if libthr is not yet initialized. The situation occurs e.g. when an LD_PRELOADed object is not linked against libthr, but the main binary is. Reported and tested by: jbeich PR: 220381 Discussed with: vangyzen Sponsored by: The FreeBSD Foundation MFC after: 13 days Modified: head/lib/libc/include/libc_private.h head/lib/libc/stdio/local.h Modified: head/lib/libc/include/libc_private.h ============================================================================== --- head/lib/libc/include/libc_private.h Fri Jun 30 20:23:46 2017 (r320508) +++ head/lib/libc/include/libc_private.h Fri Jun 30 20:27:51 2017 (r320509) @@ -415,6 +415,11 @@ void __libc_map_stacks_exec(void); void _pthread_cancel_enter(int); void _pthread_cancel_leave(int); +struct _pthread_cleanup_info; +void ___pthread_cleanup_push_imp(void (*)(void *), void *, + struct _pthread_cleanup_info *); +void ___pthread_cleanup_pop_imp(int); + void __throw_constraint_handler_s(const char * restrict msg, int error); #endif /* _LIBC_PRIVATE_H_ */ Modified: head/lib/libc/stdio/local.h ============================================================================== --- head/lib/libc/stdio/local.h Fri Jun 30 20:23:46 2017 (r320508) +++ head/lib/libc/stdio/local.h Fri Jun 30 20:27:51 2017 (r320509) @@ -148,11 +148,11 @@ void __stdio_cancel_cleanup(void *); struct _pthread_cleanup_info __cleanup_info__; \ if (__isthreaded) { \ _FLOCKFILE(fp); \ - __pthread_cleanup_push_imp( \ + ___pthread_cleanup_push_imp( \ __stdio_cancel_cleanup, (fp), \ &__cleanup_info__); \ } else { \ - __pthread_cleanup_push_imp( \ + ___pthread_cleanup_push_imp( \ __stdio_cancel_cleanup, NULL, \ &__cleanup_info__); \ } \ @@ -160,7 +160,7 @@ void __stdio_cancel_cleanup(void *); #define FUNLOCKFILE_CANCELSAFE() \ (void)0; \ } \ - __pthread_cleanup_pop_imp(1); \ + ___pthread_cleanup_pop_imp(1); \ } #endif /* _STDIO_LOCAL_H */