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

alloctracker: Fix forget() if remember() hasn't been called

If leak detector is enabled after OSv startup, the first call can be to
free(), not malloc(). Fix alloctracker::forget() to deal with that.

Fixes the SIGSEGV when "osv leak on" is used to enable detection from
gdb after OSv has started up:

  #
  # A fatal error has been detected by the Java Runtime Environment:
  #
  #  SIGSEGV (0xb) at pc=0x00000000003b8ee6, pid=0, tid=18446673706168635392
  #
  # JRE version: 7.0_25
  # Java VM: OpenJDK 64-Bit Server VM (23.7-b01 mixed mode linux-amd64 compressed oops)
  # Problematic frame:
  # C  0x00000000003b8ee6
  #
  # 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

  [penberg@localhost osv]$ addr2line -e build/debug/loader.elf
  0x00000000003b8ee6
  /home/penberg/osv/build/debug/../../core/alloctracker.cc:90
parent 65afd075
No related branches found
No related tags found
No related merge requests found
......@@ -85,6 +85,9 @@ void alloc_tracker::forget(void *addr)
if (lock.getdepth() > 1) {
return;
}
if (!allocations) {
return;
}
for (int *i = &newest_allocation; *i >= 0; i = &(allocations[*i].next)) {
if (allocations[*i].addr == addr) {
......
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