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
This commit is contained in:
kib 2017-06-30 20:27:51 +00:00
parent 6c738c519a
commit 30e6670850
2 changed files with 8 additions and 3 deletions

View File

@ -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_ */

View File

@ -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 */