ramosian-glider / sanitizers

0 stars 0 forks source link

_NSGetEnviron returns NULL on 10.6 with the dynamic runtime #118

Closed ramosian-glider closed 9 years ago

ramosian-glider commented 9 years ago

Originally reported on Google Code with ID 117

$ cat t.c
#include <stdlib.h>
int main() { 
free((void*)0x1234567);
 return 0; }

$ build/Release+Asserts/bin/clang -faddress-sanitizer t.c -c

# Everything is fine with the static runtime:
$  "/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin10/4.2.1/ld" -demangle -dynamic
-arch x86_64 -macosx_version_min 10.6.0 -o t -lcrt1.10.6.o t.o /Users/glider/src/asan/llvm/build/Release+Asserts/bin/../lib/clang/3.2/lib/darwin/libclang_rt.asan_osx.a
/usr/lib/libstdc++.6.dylib -framework CoreFoundation -lSystem /Users/glider/src/asan/llvm/build/Release+Asserts/bin/../lib/clang/3.2/lib/darwin/libclang_rt.osx.a
$ ./t
ASAN:SIGSEGV
=================================================================
==73226== ERROR: AddressSanitizer crashed on unknown address 0x00000123455f (pc 0x00010000919c
sp 0x7fff5fbff200 bp 0x7fff5fbffa30 T0)
AddressSanitizer can not provide additional info.
    #0 0x10000919b (/Users/glider/src/asan/llvm/./t+0x10000919b)
    #1 0x100001147 (/Users/glider/src/asan/llvm/./t+0x100001147)
    #2 0x100001053 (/Users/glider/src/asan/llvm/./t+0x100001053)
    #3 0x0 (/Users/glider/src/asan/llvm/./t+0x0)
Stats: 0M malloced (0M for red zones) by 0 calls
Stats: 0M realloced by 0 calls
Stats: 0M freed by 0 calls
Stats: 0M really freed by 0 calls
Stats: 0M (0 full pages) mmaped in 0 calls
  mmaps   by size class: 
  mallocs by size class: 
  frees   by size class: 
  rfrees  by size class: 
Stats: malloc large: 0 small slow: 0
==73226== ABORTING

# CHECK fails with the dynamic runtime:
$ build/Release+Asserts/bin/clang -faddress-sanitizer t.o -o t -v clang version 3.2
(trunk 165221)
Target: x86_64-apple-darwin10.8.0
Thread model: posix
 "/usr/llvm-gcc-4.2/libexec/gcc/i686-apple-darwin10/4.2.1/ld" -demangle -dynamic -arch
x86_64 -macosx_version_min 10.6.0 -o t -lcrt1.10.6.o t.o /Users/glider/src/asan/llvm/build/Release+Asserts/bin/../lib/clang/3.2/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
/usr/lib/libstdc++.6.dylib -framework CoreFoundation -lSystem /Users/glider/src/asan/llvm/build/Release+Asserts/bin/../lib/clang/3.2/lib/darwin/libclang_rt.osx.a

$ ./t
==73233== AddressSanitizer CHECK failed: /Users/glider/src/asan/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_mac.cc:99
"((env_ptr)) != (0)" (0x0, 0x0)
Stats: 0M malloced (0M for red zones) by 0 calls
Stats: 0M realloced by 0 calls
Stats: 0M freed by 0 calls
Stats: 0M really freed by 0 calls
Stats: 0M (0 full pages) mmaped in 0 calls
  mmaps   by size class: 
  mallocs by size class: 
  frees   by size class: 
  rfrees  by size class: 
Stats: malloc large: 0 small slow: 0

Reported by ramosian.glider on 2012-10-04 12:36:19

ramosian-glider commented 9 years ago

Reported by ramosian.glider on 2012-10-04 12:40:57

ramosian-glider commented 9 years ago

Reported by ramosian.glider on 2012-10-04 12:41:12

ramosian-glider commented 9 years ago
Fixed in r165227.

Reported by ramosian.glider on 2012-10-08 08:30:31

ramosian-glider commented 9 years ago
Adding Project:AddressSanitizer as part of GitHub migration.

Reported by ramosian.glider on 2015-07-30 09:13:39