[PATCH] Clear LD_PRELOAD when forking external symbolizer.
Sergey Matveev
earthdok at google.com
Mon Apr 22 09:16:01 PDT 2013
Hi kcc, glider, samsonov,
http://llvm-reviews.chandlerc.com/D704
Files:
lib/sanitizer_common/sanitizer_symbolizer_linux.cc
Index: lib/sanitizer_common/sanitizer_symbolizer_linux.cc
===================================================================
--- lib/sanitizer_common/sanitizer_symbolizer_linux.cc
+++ lib/sanitizer_common/sanitizer_symbolizer_linux.cc
@@ -36,6 +36,23 @@
static const int kSymbolizerStartupTimeMillis = 10;
+void UnsetEnvVar(const char name[]) {
+ uptr name_length = internal_strlen(name);
+ uptr i;
+ int var_index = -1;
+ for (i = 0; environ[i]; i++) {
+ if (internal_strlen(environ[i]) >= name_length + 1 &&
+ internal_strncmp(environ[i], name, name_length) == 0 &&
+ environ[i][name_length] == '=')
+ var_index = i;
+ }
+ if (var_index < 0)
+ return;
+ // environ[i - 1] is the last nonzero entry.
+ environ[var_index] = environ[i - 1];
+ environ[i - 1] = 0;
+}
+
bool StartSymbolizerSubprocess(const char *path_to_symbolizer,
int *input_fd, int *output_fd) {
if (!FileExists(path_to_symbolizer)) {
@@ -100,6 +117,7 @@
internal_close(infd[1]);
for (int fd = getdtablesize(); fd > 2; fd--)
internal_close(fd);
+ UnsetEnvVar("LD_PRELOAD");
execl(path_to_symbolizer, path_to_symbolizer, (char*)0);
internal__exit(1);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D704.1.patch
Type: text/x-patch
Size: 1228 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130422/4616644f/attachment.bin>
More information about the llvm-commits
mailing list