Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Jun 2017 20:27:51 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
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
Message-ID:  <201706302027.v5UKRpeQ001259@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706302027.v5UKRpeQ001259>