On Fri, Nov 22, 2013 at 07:21:07PM +0100, Arnaud Charlet wrote:
> > This is exactly the patch referenced in the pointer to the upstream repo.
> > Arno, does this fix the build for you?
>
> Well now I encounter:
>
> /users/charlet/fsf/trunk/libsanitizer/sanitizer_common/sanitizer_linux.cc: In
> function '__sanitizer::uptr
> __sanitizer::internal_filesize(__sanitizer::fd_t)':
> /users/charlet/fsf/trunk/libsanitizer/sanitizer_common/sanitizer_linux.cc:176:19:
> warning: 'st.stat::st_size' may be used uninitialized in this function
> [-Wmaybe-uninitialized]
> return (uptr)st.st_size;
> ^
>
> So I guess that's what we call "progress".
>
> I'll keep using --disable-libsanitizer for the time being, this library is
> clearly not quite productized yet IMO.
Here is a patch to fix various warnings, the remaining ones I'm seeing are
mostly that libsanitizer uses incorrectly C90/C++98 ... in macros (the
standard require it to be non-empty), either use the GNU extension
instead, #define INTERCEPTOR(a, b, c...) and ,## c if needed to get rid
of the preceeding comma if empty (though, you compile with -pedantic, so
might get warnings about that too), or rework the macros or have different
ones for the zero argument cases (INTERCEPTOR0).
There are some additional warnings caused by the #ifdef SYSCALL_INTERCEPTION
hacks we have to avoid various issues with problematic kernel headers or
libsanitizer code not having non-i?86/x86_64 in mind.
The sanitizer_syscall_linux_x86_64.inc changes fix real bugs, the rest is
just to get the noise level down.
--- sanitizer_common/sanitizer_linux.cc.jj 2013-11-12 11:31:00.000000000
+0100
+++ sanitizer_common/sanitizer_linux.cc 2013-11-22 20:15:26.652376137 +0100
@@ -216,7 +216,7 @@ uptr GetTid() {
}
u64 NanoTime() {
- kernel_timeval tv = {};
+ kernel_timeval tv = {0, 0};
internal_syscall(__NR_gettimeofday, (uptr)&tv, 0);
return (u64)tv.tv_sec * 1000*1000*1000 + tv.tv_usec * 1000;
}
--- sanitizer_common/sanitizer_syscall_linux_x86_64.inc.jj 2013-11-12
11:31:00.000000000 +0100
+++ sanitizer_common/sanitizer_syscall_linux_x86_64.inc 2013-11-22
20:14:32.752657581 +0100
@@ -11,7 +11,7 @@
static uptr internal_syscall(u64 nr) {
u64 retval;
- asm volatile("syscall" : "=a"(retval) : "a"(nr) : "rcx", "r11");
+ asm volatile("syscall" : "=a"(retval) : "a"(nr) : "rcx", "r11", "memory");
return retval;
}
@@ -19,7 +19,7 @@ template <typename T1>
static uptr internal_syscall(u64 nr, T1 arg1) {
u64 retval;
asm volatile("syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1) :
- "rcx", "r11");
+ "rcx", "r11", "memory");
return retval;
}
@@ -27,7 +27,7 @@ template <typename T1, typename T2>
static uptr internal_syscall(u64 nr, T1 arg1, T2 arg2) {
u64 retval;
asm volatile("syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1),
- "S"((u64)arg2) : "rcx", "r11");
+ "S"((u64)arg2) : "rcx", "r11", "memory");
return retval;
}
@@ -35,7 +35,7 @@ template <typename T1, typename T2, type
static uptr internal_syscall(u64 nr, T1 arg1, T2 arg2, T3 arg3) {
u64 retval;
asm volatile("syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1),
- "S"((u64)arg2), "d"((u64)arg3) : "rcx", "r11");
+ "S"((u64)arg2), "d"((u64)arg3) : "rcx", "r11", "memory");
return retval;
}
@@ -45,7 +45,7 @@ static uptr internal_syscall(u64 nr, T1
asm volatile("mov %5, %%r10;"
"syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1),
"S"((u64)arg2), "d"((u64)arg3), "r"((u64)arg4) :
- "rcx", "r11", "r10");
+ "rcx", "r11", "r10", "memory");
return retval;
}
@@ -57,7 +57,7 @@ static uptr internal_syscall(u64 nr, T1
"mov %6, %%r8;"
"syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1),
"S"((u64)arg2), "d"((u64)arg3), "r"((u64)arg4), "r"((u64)arg5) :
- "rcx", "r11", "r10", "r8");
+ "rcx", "r11", "r10", "r8", "memory");
return retval;
}
@@ -71,7 +71,7 @@ static uptr internal_syscall(u64 nr, T1
"mov %7, %%r9;"
"syscall" : "=a"(retval) : "a"(nr), "D"((u64)arg1),
"S"((u64)arg2), "d"((u64)arg3), "r"((u64)arg4), "r"((u64)arg5),
- "r"((u64)arg6) : "rcx", "r11", "r10", "r8", "r9");
+ "r"((u64)arg6) : "rcx", "r11", "r10", "r8", "r9", "memory");
return retval;
}
--- ubsan/ubsan_value.h.jj 2013-11-12 11:31:01.000000000 +0100
+++ ubsan/ubsan_value.h 2013-11-22 20:30:45.404835606 +0100
@@ -23,8 +23,8 @@
// FIXME: Move this out to a config header.
#if __SIZEOF_INT128__
-typedef __int128 s128;
-typedef unsigned __int128 u128;
+__extension__ typedef __int128 s128;
+__extension__ typedef unsigned __int128 u128;
#define HAVE_INT128_T 1
#else
#define HAVE_INT128_T 0
--- ubsan/ubsan_diag.h.jj 2013-08-30 21:40:13.000000000 +0200
+++ ubsan/ubsan_diag.h 2013-11-22 20:46:21.047182217 +0100
@@ -48,11 +48,11 @@ private:
public:
Location() : Kind(LK_Null) {}
Location(SourceLocation Loc) :
- Kind(LK_Source), SourceLoc(Loc) {}
+ Kind(LK_Source), SourceLoc(Loc), ModuleLoc(), MemoryLoc() {}
Location(ModuleLocation Loc) :
- Kind(LK_Module), ModuleLoc(Loc) {}
+ Kind(LK_Module), SourceLoc(), ModuleLoc(Loc), MemoryLoc() {}
Location(MemoryLocation Loc) :
- Kind(LK_Memory), MemoryLoc(Loc) {}
+ Kind(LK_Memory), SourceLoc(), ModuleLoc(), MemoryLoc(Loc) {}
LocationKind getKind() const { return Kind; }
Jakub