@@ -241,9 +241,9 @@ static LeakSuppressionContext *GetSuppressionContext() {
241
241
return suppression_ctx;
242
242
}
243
243
244
- static InternalMmapVectorNoCtor<RootRegion > root_regions;
244
+ static InternalMmapVectorNoCtor<Region > root_regions;
245
245
246
- InternalMmapVectorNoCtor<RootRegion > const *GetRootRegions () {
246
+ InternalMmapVectorNoCtor<Region > const *GetRootRegions () {
247
247
return &root_regions;
248
248
}
249
249
@@ -527,24 +527,22 @@ static void ProcessThreads(SuspendedThreadsList const &suspended_threads,
527
527
528
528
# endif // SANITIZER_FUCHSIA
529
529
530
- void ScanRootRegion (Frontier *frontier, const RootRegion &root_region,
530
+ void ScanRootRegion (Frontier *frontier, const Region &root_region,
531
531
uptr region_begin, uptr region_end, bool is_readable) {
532
532
uptr intersection_begin = Max (root_region.begin , region_begin);
533
- uptr intersection_end = Min (region_end, root_region.begin + root_region. size );
533
+ uptr intersection_end = Min (region_end, root_region.end );
534
534
if (intersection_begin >= intersection_end)
535
535
return ;
536
536
LOG_POINTERS (" Root region %p-%p intersects with mapped region %p-%p (%s)\n " ,
537
- (void *)root_region.begin ,
538
- (void *)(root_region.begin + root_region.size ),
537
+ (void *)root_region.begin , (void *)root_region.end ,
539
538
(void *)region_begin, (void *)region_end,
540
539
is_readable ? " readable" : " unreadable" );
541
540
if (is_readable)
542
541
ScanRangeForPointers (intersection_begin, intersection_end, frontier, " ROOT" ,
543
542
kReachable );
544
543
}
545
544
546
- static void ProcessRootRegion (Frontier *frontier,
547
- const RootRegion &root_region) {
545
+ static void ProcessRootRegion (Frontier *frontier, const Region &root_region) {
548
546
MemoryMappingLayout proc_maps (/* cache_enabled*/ true );
549
547
MemoryMappedSegment segment;
550
548
while (proc_maps.Next (&segment)) {
@@ -1014,7 +1012,8 @@ SANITIZER_INTERFACE_ATTRIBUTE
1014
1012
void __lsan_register_root_region (const void *begin, uptr size) {
1015
1013
#if CAN_SANITIZE_LEAKS
1016
1014
Lock l (&global_mutex);
1017
- RootRegion region = {reinterpret_cast <uptr>(begin), size};
1015
+ Region region = {reinterpret_cast <uptr>(begin),
1016
+ reinterpret_cast <uptr>(begin) + size};
1018
1017
root_regions.push_back (region);
1019
1018
VReport (1 , " Registered root region at %p of size %zu\n " , begin, size);
1020
1019
#endif // CAN_SANITIZE_LEAKS
@@ -1025,9 +1024,10 @@ void __lsan_unregister_root_region(const void *begin, uptr size) {
1025
1024
#if CAN_SANITIZE_LEAKS
1026
1025
Lock l (&global_mutex);
1027
1026
bool removed = false ;
1027
+ uptr end = reinterpret_cast <uptr>(begin) + size;
1028
1028
for (uptr i = 0 ; i < root_regions.size (); i++) {
1029
- RootRegion region = root_regions[i];
1030
- if (region.begin == reinterpret_cast <uptr>(begin) && region.size == size ) {
1029
+ Region region = root_regions[i];
1030
+ if (region.begin == reinterpret_cast <uptr>(begin) && region.end == end ) {
1031
1031
removed = true ;
1032
1032
uptr last_index = root_regions.size () - 1 ;
1033
1033
root_regions[i] = root_regions[last_index];
0 commit comments