Skip to content

Commit cb8382e

Browse files
Jiri Olsaacmel
authored andcommitted
perf tools: Insert split maps correctly into origin group
When new maps are cloned out of split map they are added into origin map's group, but their groups pointer is not updated. This could lead to a segfault, because map->groups is expected to be always set as reported by Markus: __map__is_kernel (map=map@entry=0x1abb7a0) at util/map.c:238 238 return __machine__kernel_map(map->groups->machine, map->type) = (gdb) bt #0 __map__is_kernel (map=map@entry=0x1abb7a0) at util/map.c:238 raspberrypi#1 0x00000000004393e4 in symbol_filter (map=map@entry=0x1abb7a0, sym=sym@entry raspberrypi#2 0x00000000004fcd4d in dso__load_sym (dso=dso@entry=0x166dae0, map=map@entry raspberrypi#3 0x00000000004a64e0 in dso__load (dso=0x166dae0, map=map@entry=0x1abb7a0, fi raspberrypi#4 0x00000000004b941f in map__load (filter=0x4393c0 <symbol_filter>, map=<opti raspberrypi#5 map__find_symbol (map=0x1abb7a0, addr=40188, filter=0x4393c0 <symbol_filter ... Adding __map_groups__insert function to add map into groups together with map->groups pointer update. It takes no lock as opposed to existing map_groups__insert, as maps__fixup_overlappings(), where it is being called, already has the necessary lock held. Using __map_groups__insert to add new maps after map split. Reported-by: Markus Trippelsdorf <markus@trippelsdorf.de> Signed-off-by: Jiri Olsa <jolsa@kernel.org> Tested-by: Markus Trippelsdorf <markus@trippelsdorf.de> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/20151104140811.GA32664@krava.brq.redhat.com Fixes: cfc5acd ("perf top: Filter symbols based on __map__is_kernel(map)") Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent eedfcb4 commit cb8382e

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

‎tools/perf/util/map.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,12 @@ size_t map_groups__fprintf(struct map_groups *mg, FILE *fp)
644644
return printed;
645645
}
646646

647+
static void __map_groups__insert(struct map_groups *mg, struct map *map)
648+
{
649+
__maps__insert(&mg->maps[map->type], map);
650+
map->groups = mg;
651+
}
652+
647653
static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp)
648654
{
649655
struct rb_root *root;
@@ -682,7 +688,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp
682688
}
683689

684690
before->end = map->start;
685-
__maps__insert(maps, before);
691+
__map_groups__insert(pos->groups, before);
686692
if (verbose >= 2)
687693
map__fprintf(before, fp);
688694
}
@@ -696,7 +702,7 @@ static int maps__fixup_overlappings(struct maps *maps, struct map *map, FILE *fp
696702
}
697703

698704
after->start = map->end;
699-
__maps__insert(maps, after);
705+
__map_groups__insert(pos->groups, after);
700706
if (verbose >= 2)
701707
map__fprintf(after, fp);
702708
}

0 commit comments

Comments
 (0)