Hi!

glibc recently changed a couple of headers.  One change was
that typedef struct sigaltstack { ... } stack_t; is now
typedef struct { ... } stack_t;
and the other change is that resolv.h now ignores the former (private glibc
macro) __need_res_state macro and after
struct __res_state { ... };
typedef struct __res_state *res_state;
also newly adds
extern struct __res_state *__res_state(void) __attribute__ ((__const__));
declaration even if that macro is defined.

The following patch fixes both of these issues and should work even with
older glibcs.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.
Will backport to release branches soon.

2017-07-14  Jakub Jelinek  <ja...@redhat.com>

        PR sanitizer/81066
        * sanitizer_common/sanitizer_linux.h: Cherry-pick upstream r307969.
        * sanitizer_common/sanitizer_linux.cc: Likewise.
        * sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc: Likewise.
        * tsan/tsan_platform_linux.cc: Likewise.

--- libsanitizer/sanitizer_common/sanitizer_linux.h     (revision 307968)
+++ libsanitizer/sanitizer_common/sanitizer_linux.h     (revision 307969)
@@ -21,7 +21,6 @@
 #include "sanitizer_platform_limits_posix.h"
 
 struct link_map;  // Opaque type returned by dlopen().
-struct sigaltstack;
 
 namespace __sanitizer {
 // Dirent structure for getdents(). Note that this structure is different from
@@ -30,8 +29,7 @@ struct linux_dirent;
 
 // Syscall wrappers.
 uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count);
-uptr internal_sigaltstack(const struct sigaltstack* ss,
-                          struct sigaltstack* oss);
+uptr internal_sigaltstack(const void* ss, void* oss);
 uptr internal_sigprocmask(int how, __sanitizer_sigset_t *set,
     __sanitizer_sigset_t *oldset);
 
--- libsanitizer/sanitizer_common/sanitizer_linux.cc    (revision 307968)
+++ libsanitizer/sanitizer_common/sanitizer_linux.cc    (revision 307969)
@@ -629,8 +629,7 @@ uptr internal_prctl(int option, uptr arg
 }
 #endif
 
-uptr internal_sigaltstack(const struct sigaltstack *ss,
-                         struct sigaltstack *oss) {
+uptr internal_sigaltstack(const void *ss, void *oss) {
   return internal_syscall(SYSCALL(sigaltstack), (uptr)ss, (uptr)oss);
 }
 
--- libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc       
(revision 307968)
+++ libsanitizer/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc       
(revision 307969)
@@ -287,7 +287,7 @@ static int TracerThread(void* argument)
 
   // Alternate stack for signal handling.
   InternalScopedBuffer<char> handler_stack_memory(kHandlerStackSize);
-  struct sigaltstack handler_stack;
+  stack_t handler_stack;
   internal_memset(&handler_stack, 0, sizeof(handler_stack));
   handler_stack.ss_sp = handler_stack_memory.data();
   handler_stack.ss_size = kHandlerStackSize;
--- libsanitizer/tsan/tsan_platform_linux.cc    (revision 307968)
+++ libsanitizer/tsan/tsan_platform_linux.cc    (revision 307969)
@@ -286,7 +286,7 @@ void InitializePlatform() {
 int ExtractResolvFDs(void *state, int *fds, int nfd) {
 #if SANITIZER_LINUX && !SANITIZER_ANDROID
   int cnt = 0;
-  __res_state *statp = (__res_state*)state;
+  struct __res_state *statp = (struct __res_state*)state;
   for (int i = 0; i < MAXNS && cnt < nfd; i++) {
     if (statp->_u._ext.nsaddrs[i] && statp->_u._ext.nssocks[i] != -1)
       fds[cnt++] = statp->_u._ext.nssocks[i];

        Jakub

Reply via email to