[PATCH] D11389: [asan] Fix the freopen interceptor to allow NULL instead of a filename

Kuba Brecka via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 27 04:27:39 PDT 2015


kubabrecka removed rL LLVM as the repository for this revision.
kubabrecka updated this revision to Diff 33311.
kubabrecka added a comment.

OK, I was able to reproduce the i386 Linux test failure.  It looks like it has little to do with the actual patch/fix, but instead it's a more general issue with versioned symbols from glibc – freopen is a versioned symbol (and incompatible between versions), and when it's intercepted, a wrong version is called.  Even this fails (with or without this patch):

  FILE *fp = fopen("/dev/null", "w");
  freopen("/dev/null", "r", fp);
  fclose(fp);

This seems to be a Linux-specific issue, and frankly, I don't know what to do about it.  In the meantime, I'm suggesting to commit this patch without the testcase.  Updating the diff.


http://reviews.llvm.org/D11389

Files:
  lib/sanitizer_common/sanitizer_common_interceptors.inc

Index: lib/sanitizer_common/sanitizer_common_interceptors.inc
===================================================================
--- lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -4761,7 +4761,7 @@
             __sanitizer_FILE *fp) {
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, freopen, path, mode, fp);
-  COMMON_INTERCEPTOR_READ_RANGE(ctx, path, REAL(strlen)(path) + 1);
+  if (path) COMMON_INTERCEPTOR_READ_RANGE(ctx, path, REAL(strlen)(path) + 1);
   COMMON_INTERCEPTOR_READ_RANGE(ctx, mode, REAL(strlen)(mode) + 1);
   COMMON_INTERCEPTOR_FILE_CLOSE(ctx, fp);
   __sanitizer_FILE *res = REAL(freopen)(path, mode, fp);
@@ -4792,7 +4792,7 @@
             __sanitizer_FILE *fp) {
   void *ctx;
   COMMON_INTERCEPTOR_ENTER(ctx, freopen64, path, mode, fp);
-  COMMON_INTERCEPTOR_READ_RANGE(ctx, path, REAL(strlen)(path) + 1);
+  if (path) COMMON_INTERCEPTOR_READ_RANGE(ctx, path, REAL(strlen)(path) + 1);
   COMMON_INTERCEPTOR_READ_RANGE(ctx, mode, REAL(strlen)(mode) + 1);
   COMMON_INTERCEPTOR_FILE_CLOSE(ctx, fp);
   __sanitizer_FILE *res = REAL(freopen64)(path, mode, fp);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11389.33311.patch
Type: text/x-patch
Size: 1152 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150827/49833d52/attachment.bin>


More information about the llvm-commits mailing list