Re: CVS commit: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common

2020-09-05 Thread Kamil Rytarowski
On 05.09.2020 15:35, matthew green wrote:
> Module Name:  src
> Committed By: mrg
> Date: Sat Sep  5 13:35:55 UTC 2020
> 
> Modified Files:
>   src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
>   sanitizer_linux.cc sanitizer_linux.h sanitizer_linux_libcdep.cc
>   sanitizer_platform_limits_netbsd.cc sanitizer_syscall_generic.inc
> 
> Log Message:
> fix various merge botches; we may need to re-port the ThreadLister code.
> 


LSan was ported and upstreamed post GCC-9:

https://github.com/llvm/llvm-project/commit/1b58389428ed07a7322ba9c2bcaeec99807f9457

https://github.com/llvm/llvm-project/commit/5fe1e55d35413b1904cfcf16ec15495398921fe5

https://github.com/llvm/llvm-project/commit/8827047551570b7ed7088765c3de2a8cce6823b8

https://github.com/llvm/llvm-project/commit/983d7ddd0b278b45d815cbac9197205b39c4860a

https://github.com/llvm/llvm-project/commit/fc356dcc11c10003ff22acff667b0a9f5e6c1e0f

https://github.com/llvm/llvm-project/commit/3a189bac9bb111c9a59339015ab0d4e2fed735f4

https://github.com/llvm/llvm-project/commit/02519fc7a6f8c528f67975a9f78ce64dabf402b4

And possibly something else:

https://github.com/llvm/llvm-project/commits?author=krytarowski

> 
> To generate a diff of this commit:
> cvs rdiff -u -r1.33 -r1.34 \
> 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc
> cvs rdiff -u -r1.9 -r1.10 \
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.h
> cvs rdiff -u -r1.12 -r1.13 \
> 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc
> cvs rdiff -u -r1.1.1.2 -r1.2 \
> 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc
> cvs rdiff -u -r1.8 -r1.9 \
> 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc
> 
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.
> 
> 
> Modified files:
> 
> Index: 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc
> diff -u 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc:1.33
>  
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc:1.34
> --- 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc:1.33
>   Sat Sep  5 09:12:32 2020
> +++ 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc   
> Sat Sep  5 13:35:55 2020
> @@ -41,8 +41,6 @@
>  #undef stat
>  #endif
>  
> -#endif // SANITIZER_LINUX
> -
>  #if SANITIZER_NETBSD
>  #include 
>  #endif
> @@ -980,7 +978,6 @@ ThreadLister::ThreadLister(pid_t pid) : 
>if (internal_iserror(descriptor_)) {
>  Report("Can't open /proc/%d/task for reading.\n", pid);
>}
> -#endif
>  }
>  
>  ThreadLister::Result ThreadLister::ListThreads(
> @@ -1055,10 +1052,8 @@ bool ThreadLister::IsAlive(int tid) {
>  }
>  
>  ThreadLister::~ThreadLister() {
> -#ifndef SANITIZER_NETBSD
>if (!internal_iserror(descriptor_))
>  internal_close(descriptor_);
> -#endif
>  }
>  #endif
>  
> 
> Index: 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.h
> diff -u 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.h:1.9
>  
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.h:1.10
> --- 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.h:1.9
> Sat Sep  5 09:12:32 2020
> +++ 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.h
> Sat Sep  5 13:35:55 2020
> @@ -69,6 +69,8 @@ uptr internal_clone(int (*fn)(void *), v
>  #endif
>  #elif SANITIZER_FREEBSD
>  void internal_sigdelset(__sanitizer_sigset_t *set, int signum);
> +#elif SANITIZER_NETBSD
> +uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr arg5);
>  #endif  // SANITIZER_LINUX
>  
>  #ifdef SANITIZER_NETBSD
> 
> Index: 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc
> diff -u 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc:1.12
>  
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc:1.13
> --- 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc:1.12
>   Sat Sep  5 09:12:32 2020
> +++ 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux_libcdep.cc
>Sat Sep  5 13:35:55 2020
> @@ -72,6 +72,10 @@ struct __sanitizer::linux_dirent {
>  #include 
>  #endif
>  
> +#if SANITIZER_NETBSD
> +#include 
> +#endif
> +
>  namespace __sanitizer {
>  
>  SANITIZER_WEAK_ATTRIBUTE int
> 
> Index: 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc
> diff -u 
> src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_netbsd.cc:1.1.1.2
>  
> 

CVS commit: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common

2019-06-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jun  1 17:24:20 UTC 2019

Modified Files:
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
sanitizer_linux.cc

Log Message:
Don't require procfs to be mounted with linux so that /task is available
and explain why.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 \
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common

2019-06-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jun  1 17:24:20 UTC 2019

Modified Files:
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
sanitizer_linux.cc

Log Message:
Don't require procfs to be mounted with linux so that /task is available
and explain why.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 \
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc
diff -u src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc:1.30 src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc:1.31
--- src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc:1.30	Fri Apr 26 20:23:17 2019
+++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc	Sat Jun  1 13:24:20 2019
@@ -854,6 +854,18 @@ ThreadLister::ThreadLister(int pid)
 error_(true),
 entry_((struct linux_dirent *)buffer_.data()),
 bytes_read_(0) {
+#if SANITIZER_NETBSD
+  /*
+   * netbsd does not have "tasks". Our lwp's are not like processes, 
+   * and this is used to suspend each task by attaching to them and stopping
+   * them. We do this at the process level, so we hijack the descriptor to
+   * permanently store our pid (the pid to trace and stop), and bytes_read_
+   * to store a copy of it, that we set to -1 once we read it.
+   */
+  descriptor_ = pid;
+  bytes_read_ = pid;
+  error_ = false;
+#else
   char task_directory_path[80];
   internal_snprintf(task_directory_path, sizeof(task_directory_path),
 "/proc/%d/task/", pid);
@@ -865,9 +877,15 @@ ThreadLister::ThreadLister(int pid)
 error_ = false;
 descriptor_ = openrv;
   }
+#endif
 }
 
 int ThreadLister::GetNextTID() {
+#if SANITIZER_NETBSD
+  int tid = bytes_read_;
+  bytes_read_ = -1;
+  return tid;
+#else
   int tid = -1;
   do {
 if (error_)
@@ -882,17 +900,25 @@ int ThreadLister::GetNextTID() {
 entry_ = (struct linux_dirent *)(((char *)entry_) + entry_->d_reclen);
   } while (tid < 0);
   return tid;
+#endif
 }
 
 void ThreadLister::Reset() {
+#if SANITIZER_NETBSD
+  bytes_read_ = descriptor_;
+  error_ = false;
+#else
   if (error_ || descriptor_ < 0)
 return;
   internal_lseek(descriptor_, 0, SEEK_SET);
+#endif
 }
 
 ThreadLister::~ThreadLister() {
+#ifndef SANITIZER_NETBSD
   if (descriptor_ >= 0)
 internal_close(descriptor_);
+#endif
 }
 
 bool ThreadLister::error() { return error_; }



re: CVS commit: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common

2016-09-22 Thread Christos Zoulas
On Sep 22,  4:02pm, m...@eterna.com.au (matthew green) wrote:
-- Subject: re: CVS commit: src/external/gpl3/gcc/dist/libsanitizer/sanitizer

| sorry to bug you again, but... ;)
| 
| > Modified Files:
| > src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
| > sanitizer_platform_limits_posix.h
| > 
| > Log Message:
| > Check the NetBSD version
| 
| ! # ifdef __NetBSD__
| 
| hmmm, shouldn't that be SANITZIER_NETBSD or whatever it is?

Could be... I've changed it.

christos


re: CVS commit: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common

2016-09-22 Thread matthew green
sorry to bug you again, but... ;)

> Modified Files:
>   src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
>   sanitizer_platform_limits_posix.h
> 
> Log Message:
> Check the NetBSD version

! # ifdef __NetBSD__

hmmm, shouldn't that be SANITZIER_NETBSD or whatever it is?


re: CVS commit: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common

2016-09-21 Thread matthew green
"Christos Zoulas" writes:
> Module Name:  src
> Committed By: christos
> Date: Wed Sep 21 19:18:01 UTC 2016
> 
> Modified Files:
>   src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
>   sanitizer_platform_limits_posix.h
> 
> Log Message:
> add new field

+ #ifdef __NetBSD__
+ unsigned int ifa_addrflags;
+ #endif

thanks for cleaning up :-)

can you make this version specific so that we can upstream this
change?  the above only works on todays netbsd.

thanks.


.mrg.


Re: CVS commit: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common

2016-06-10 Thread Rin Okuyama

On 2016/06/09 23:37, Christos Zoulas wrote:

Module Name:src
Committed By:   christos
Date:   Thu Jun  9 14:37:06 UTC 2016

Modified Files:
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
sanitizer_linux.cc sanitizer_syscall_generic.inc

Log Message:
Fix syscall argument passing from Ryn Okuyama (with minor changes; hope I did
not make it worse :-)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc
cvs rdiff -u -r1.2 -r1.3 \

src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.


Thank you very much for refinement and commit my patch. Let me add
few comments:

* internal_ptrace()

   As usage of ptrace(2) is quite different for Linux and us, we need
   additional work to get it working. At this moment, this function is
   used only within "#if SANITIZER_LINUX && defined(__x86_64__)" block
   in sanitizer_stoptheworld_linux_libcdep.cc. This is why I disabled
   it in my previous patch. I've added a brief comment.

* internal_wait4()

   The last argument of wait4(2) should be NULL, not 0. This may
   cause troubles for LP64.

* internal_getdents()

   Sorry, my previous patch for this function was completely wrong.
   But your version is also incomplete:

 - structure dirent is different for Linux and us; we need to
   declare linux_dirent in the same way as our native dirent.

 - The last argument of getdents(2) should be size_t (aka uptr),
   not u_int.

* sanitizer_syscall_generic.inc

   Sorry, this is also my careless mistake. Two #if blocks should
   be combined to avoid possible redefinition of internal_syscall.

Thanks,
Rin

--- 
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc.orig
2016-06-10 06:14:51.159752456 +0900
+++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc 
2016-06-10 09:16:19.561985484 +0900
@@ -56,6 +56,7 @@
  extern char **environ;  // provided by crt1
  #endif  // SANITIZER_FREEBSD
  #if SANITIZER_NETBSD
+#include  // for NAME_MAX
  #include 
  extern char **environ;  // provided by crt1
  #endif  // SANITIZER_NETBSD
@@ -491,6 +492,17 @@
  }
  
  // - sanitizer_linux.h

+#if SANITIZER_NETBSD
+// struct dirent is different for Linux and us. At this moment, we use only
+// d_fileno (Linux call this d_ino), d_reclen, and d_name.
+struct linux_dirent {
+  u64  d_ino; // d_fileno
+  u16  d_reclen;
+  u16  d_namlen;  // not used
+  u8   d_type;// not used
+  char d_name[NAME_MAX + 1];
+};
+#else
  // The actual size of this structure is specified by d_reclen.
  // Note that getdents64 uses a different structure format. We only provide the
  // 32-bit syscall here.
@@ -505,10 +517,18 @@
unsigned short d_reclen;
char   d_name[256];
  };
+#endif
  
  // Syscall wrappers.

  uptr internal_ptrace(int request, int pid, void *addr, void *data) {
  #if SANITIZER_NETBSD
+// XXX We need additional work for ptrace:
+//   - for request, we use PT_FOO whereas Linux uses PTRACE_FOO
+//   - data is int for us, but void * for Linux
+//   - Linux sometimes uses data in the case where we use addr instead
+// At this moment, this function is used only within
+// "#if SANITIZER_LINUX && defined(__x86_64__)" block in
+// sanitizer_stoptheworld_linux_libcdep.cc.
return internal_syscall_ptr(SYSCALL(ptrace), request, pid, (uptr)addr,
(uptr)data);
  #else
@@ -518,8 +538,13 @@
  }
  
  uptr internal_waitpid(int pid, int *status, int options) {

+#if SANITIZER_NETBSD
+  return internal_syscall(SYSCALL(wait4), pid, status, options,
+  NULL /* rusage */);
+#else
return internal_syscall(SYSCALL(wait4), pid, (uptr)status, options,
0 /* rusage */);
+#endif
  }
  
  uptr internal_getpid() {

@@ -531,7 +556,9 @@
  }
  
  uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count) {

-#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
+#if SANITIZER_NETBSD
+  return internal_syscall(SYSCALL(getdents), fd, dirp, (uptr)count);
+#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
return internal_syscall(SYSCALL(getdents64), fd, (uptr)dirp, count);
  #else
return internal_syscall(SYSCALL(getdents), fd, (uptr)dirp, count);
--- 
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc.orig
 2016-06-10 07:09:34.310819833 +0900
+++ 
src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc
  2016-06-10 07:09:51.201896163 +0900
@@ -38,9 +38,7 @@
  # else
  #  define internal_syscall_ptrsyscall
  # endif
-#endif
-
-#if (SANITIZER_FREEBSD && defined(__x86_64__))
+#elif (SANITIZER_FREEBSD && defined(__x86_64__))
  # define internal_syscall __syscall
  #