Skip to content

Commit

Permalink
Fix memory leak in performance schema unit test pfs-t
Browse files Browse the repository at this point in the history
Summary:
Fix the following leak reported by ASAN:

  ==2475771==ERROR: LeakSanitizer: detected memory leaks

  Direct leak of 40 byte(s) in 1 object(s) allocated from:
      #0 0x7f97e37fb151 in __interceptor_calloc (/usr/local/fbcode/gcc-5-glibc-2.23/lib/libasan.so.2+0x9a151)
      #1 0x445229 in my_malloc /home/tianx/mysql/5.6/mysys/my_malloc.c:38
      #2 0x44b908 in _lf_alloc_new /home/tianx/mysql/5.6/mysys/lf_alloc-pin.c:440
      #3 0x44dfd0 in lf_hash_insert /home/tianx/mysql/5.6/mysys/lf_hash.c:390
      #4 0x416220 in find_or_create_file(PFS_thread*, PFS_file_class*, char const*, unsigned int, bool) /home/tianx/mysql/5.6/storage/perfschema/pfs_instr.cc:1353
      #5 0x439265 in create_file_v1 /home/tianx/mysql/5.6/storage/perfschema/pfs.cc:1791
      #6 0x4099f6 in test_locker_disabled() /home/tianx/mysql/5.6/storage/perfschema/unittest/pfs-t.cc:1150
      #7 0x40aef7 in do_all_tests() /home/tianx/mysql/5.6/storage/perfschema/unittest/pfs-t.cc:1659
      #8 0x403d38 in main /home/tianx/mysql/5.6/storage/perfschema/unittest/pfs-t.cc:1668
      #9 0x7f97e2288857 in __libc_start_main (/usr/local/fbcode/gcc-5-glibc-2.23/lib/libc.so.6+0x20857)
      #10 0x404bf8 in _start (/data/users/tianx/mysql/5.6/_build-5.6-ASan-PerfSchema/storage/perfschema/unittest/pfs-t+0x404bf8)

  SUMMARY: AddressSanitizer: 40 byte(s) leaked in 1 allocation(s).

It seems the instrumented file's name is normalized to contain `-instrumented`
in it. Previously test wasn't able to clean up the instrumented file "foo".

Depends on D5235521

Test Plan:
mtr

mysqltest.sh --asan --perfschema --unit-tests --unit-tests-report empty_table

Reviewers: gunnarku

Reviewed By: gunnarku

Subscribers: webscalesql-eng@fb.com

Differential Revision: https://phabricator.intern.facebook.com/D5235559

Tasks: 17217920

Signature: t1:5235559:1497365801:a1b886d1f09005cd17196dfa44837e4336a5dfe5
  • Loading branch information
tianx committed Jun 13, 2017
1 parent 330fc65 commit 8493330
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions storage/perfschema/unittest/pfs-t.cc
Expand Up @@ -1147,9 +1147,9 @@ void test_locker_disabled()
ok(cond_A1 != NULL, "instrumented");

file_class_A->m_enabled= true;
psi->create_file(file_key_A, "foo", (File) 12);
file_A1= (PSI_file*) lookup_file_by_name("foo");
ok(file_A1 != NULL, "instrumented");
psi->create_file(file_key_A, "foo-instrumented", (File) 12);
file_A1= (PSI_file*) lookup_file_by_name("foo-instrumented");
ok(file_A1 != NULL, "file_A1 instrumented");

socket_class_A->m_enabled= true;
socket_A1= psi->init_socket(socket_key_A, NULL, NULL, 0);
Expand Down

0 comments on commit 8493330

Please sign in to comment.