Skip to content
Snippets Groups Projects
Commit eff44bc7 authored by Pekka Enberg's avatar Pekka Enberg
Browse files

callstack: Fix list iteration in callstack_collector::merge()

Call to erase() invalidates iterators so switch from range-based for
loop to using iterators manually.

This fixes a bug that resulted in JVM crashing on SMP when "perf
callstack" was run:

  #
  # A fatal error has been detected by the Java Runtime Environment:
  #
  #  SIGSEGV (0xb) at pc=0x0000000000328a44, pid=0, tid=18446673706080178176
  #
  # JRE version: 7.0_19
  # Java VM: OpenJDK 64-Bit Server VM (23.7-b01 mixed mode linux-amd64 compressed oops)
  # Problematic frame:
  # C  0x0000000000328a44
  #
  # Core dump written. Default location: //core or core.0
  #
  # An error report file with more information is saved as:
  # /tmp/jvm-0/hs_error.log
  #
  # If you would like to submit a bug report, please include
  # instructions on how to reproduce the bug and visit:
  #   http://icedtea.classpath.org/bugzilla
  #
  Aborted
parent da3e7b76
No related branches found
No related tags found
No related merge requests found
......@@ -59,12 +59,15 @@ void callstack_collector::merge()
continue;
}
auto& table = **_table.for_cpu(c);
for (auto& tr : table) {
auto it = table.begin();
while (it != table.end()) {
trace& tr = *it;
auto i = table0.find(tr);
if (i != table0.end()) {
i->hits += tr.hits;
++it;
} else {
table.erase(table.iterator_to(tr));
table.erase(it++);
table0.insert(tr);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment