On OS X, when the main instrumented binary contains a custom section with zero length, ASan will crash (assert failure) early in the initialization. This can be reproduced with a linker option -sectcreate mysegment mysection /dev/null. Running such a binary with ASan produces just:
$ ./a.out ==38355==AddressSanitizer CHECK failed: .../llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_posix.cc:258 "((start1 <= end1)) != (0)" (0x0, 0x0)
There seems to be an off-by-one bug in MemoryRangeIsAvailable, this patch fixes it and adds a regression test.
This is incorrect. IntervalsAreSeparate and MemoryRangeIsAvailable assume that start and end are inclusive (just audit its code and uses).
You need a special case for zero-size interval.