[PATCH] D19027: [sanitizer] remove PS_STRINGS fallback on FreeBSD
Ed Maste via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 12 12:46:37 PDT 2016
emaste created this revision.
emaste added reviewers: samsonov, dim, davide.
emaste added a subscriber: llvm-commits.
Herald added a subscriber: emaste.
The `PS_STRINGS` constant can easily be incorrect with mismatched kernel/userland - e.g. when building i386 sanitizers on FreeBSD/amd64 with `-m32`. The `kern.ps_strings` sysctl exists on all supported versions of FreeBSD and is the supported way to get the environment and argument strings, so we never use the `PS_STRINGS` fallback. Just remove it.
http://reviews.llvm.org/D19027
Files:
lib/sanitizer_common/sanitizer_linux.cc
Index: lib/sanitizer_common/sanitizer_linux.cc
===================================================================
--- lib/sanitizer_common/sanitizer_linux.cc
+++ lib/sanitizer_common/sanitizer_linux.cc
@@ -464,12 +464,13 @@
#else
// On FreeBSD, retrieving the argument and environment arrays is done via the
// kern.ps_strings sysctl, which returns a pointer to a structure containing
- // this information. If the sysctl is not available, a "hardcoded" address,
- // PS_STRINGS, must be used instead. See also <sys/exec.h>.
+ // this information. See also <sys/exec.h>.
ps_strings *pss;
size_t sz = sizeof(pss);
- if (sysctlbyname("kern.ps_strings", &pss, &sz, NULL, 0) == -1)
- pss = (ps_strings*)PS_STRINGS;
+ if (sysctlbyname("kern.ps_strings", &pss, &sz, NULL, 0) == -1) {
+ Printf("sysctl kern.ps_strings failed\n");
+ Die();
+ }
*argv = pss->ps_argvstr;
*envp = pss->ps_envstr;
#endif
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19027.53443.patch
Type: text/x-patch
Size: 930 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160412/60662a95/attachment.bin>
More information about the llvm-commits
mailing list