[compiler-rt] r226913 - [sanitizer] Fix an edge case in MemoryRangeIsAvailable.

Alexey Samsonov vonosmas at gmail.com
Fri Jan 30 10:44:43 PST 2015


On Fri, Jan 30, 2015 at 9:37 AM, Evgeniy Stepanov <eugeni.stepanov at gmail.com
> wrote:

> MemoryRangeIsAvailable treats its argument as [range_start, range_end].
> MemoryMappingLayout returns [start, end) intervals.
> IntervalsAreSeparate treats both intervals as [start, end].
> Looks like the current code is correct, but quite confusing. Shall we
> switch to [start, end) intervals everywhere?
>

Yes, I think that would be the best option.


>
>
>
> On Tue, Jan 27, 2015 at 3:48 PM, Alexey Samsonov <vonosmas at gmail.com>
> wrote:
> > On Fri, Jan 23, 2015 at 7:14 AM, Evgeniy Stepanov
> > <eugeni.stepanov at gmail.com> wrote:
> >>
> >> Author: eugenis
> >> Date: Fri Jan 23 09:14:27 2015
> >> New Revision: 226913
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=226913&view=rev
> >> Log:
> >> [sanitizer] Fix an edge case in MemoryRangeIsAvailable.
> >>
> >> Modified:
> >>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
> >>
> >> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc?rev=226913&r1=226912&r2=226913&view=diff
> >>
> >>
> ==============================================================================
> >> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc (original)
> >> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_posix.cc Fri Jan 23
> >> 09:14:27 2015
> >> @@ -237,7 +237,8 @@ bool MemoryRangeIsAvailable(uptr range_s
> >>    while (proc_maps.Next(&start, &end,
> >>                          /*offset*/0, /*filename*/0, /*filename_size*/0,
> >>                          /*protection*/0)) {
> >> -    if (!IntervalsAreSeparate(start, end, range_start, range_end))
> >> +    CHECK_NE(0, end);
> >> +    if (!IntervalsAreSeparate(start, end - 1, range_start, range_end))
> >>        return false;
> >>    }
> >
> >
> > I don't believe this is the correct fix. IntervalsAreSeparate should
> treat
> > its arguments as [start1, end1) and [start2, end2), and
> > therefore check that (end1 <= start2) || (end2 <= start1);
> >
> > Otherwise, your change should also subtract one from range_end.
> >
> >>
> >>    return true;
> >>
> >>
> >> _______________________________________________
> >> llvm-commits mailing list
> >> llvm-commits at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >
> >
> >
> >
> > --
> > Alexey Samsonov
> > vonosmas at gmail.com
>



-- 
Alexey Samsonov
vonosmas at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150130/19ca183e/attachment.html>


More information about the llvm-commits mailing list