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 */
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to