Use xfree rather than delete for varobj_iter
authorYao Qi <yao.qi@linaro.org>
Thu, 23 Feb 2017 11:57:46 +0000 (11:57 +0000)
committerYao Qi <yao.qi@linaro.org>
Thu, 23 Feb 2017 11:57:46 +0000 (11:57 +0000)
ASAN reports an error,

-var-create container @ c^M
=================================================================^M
^[[1m^[[31m==21639==ERROR: AddressSanitizer: alloc-dealloc-mismatch (malloc vs operator delete) on 0x6030000805c0^M
^[[1m^[[0m    #0 0x7f2449b01b2a in operator delete(void*) (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x99b2a)^M
    #1 0xbb601d in update_dynamic_varobj_children ../../binutils-gdb/gdb/varobj.c:794^M
    #2 0xbb6556 in varobj_get_num_children(varobj*) ../../binutils-gdb/gdb/varobj.c:854^M
    #3 0x580cb4 in print_varobj ../../binutils-gdb/gdb/mi/mi-cmd-var.c:61^M
    #4 0x58138b in mi_cmd_var_create(char*, char**, int) ../../binutils-gdb/gdb/mi/mi-cmd-var.c:145^M
    #5 0x5967ce in mi_cmd_execute ../../binutils-gdb/gdb/mi/mi-main.c:2301^M
    #6 0x594b05 in captured_mi_execute_command ../../binutils-gdb/gdb/mi/mi-main.c:2001
....
^M
^[[1m^[[32m0x6030000805c0 is located 0 bytes inside of 32-byte region [0x6030000805c0,0x6030000805e0)^M
^[[1m^[[0m^[[1m^[[35mallocated by thread T0 here:^[[1m^[[0m^M
    #0 0x7f2449b00602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)^M
    #1 0x7d1596 in xmalloc ../../binutils-gdb/gdb/common/common-utils.c:43^M
    #2 0x604176 in py_varobj_iter_new ../../binutils-gdb/gdb/python/py-varobj.c:159^M
    #3 0x6042da in py_varobj_get_iterator(varobj*, _object*) ../../binutils-gdb/gdb/python/py-varobj.c:198^M
    #4 0xbb5806 in varobj_get_iterator ../../binutils-gdb/gdb/varobj.c:720^M
    #5 0xbb5b9b in update_dynamic_varobj_children ../../binutils-gdb/gdb/varobj.c:758^M

gdb:

2017-02-23  Yao Qi  <yao.qi@linaro.org>

* varobj-iter.h (varobj_iter_delete): Call xfree instead of
delete.

gdb/ChangeLog
gdb/varobj-iter.h

index ade40bd8d487f877e6ad08a69e5bc1c53848d83b..6cc163b3dee5fb111fac88aaffd5c9050ebb384e 100644 (file)
@@ -1,3 +1,8 @@
+2017-02-23  Yao Qi  <yao.qi@linaro.org>
+
+       * varobj-iter.h (varobj_iter_delete): Call xfree instead of
+       delete.
+
 2017-02-23  Yao Qi  <yao.qi@linaro.org>
 
        * varobj.c (varobj_clear_saved_item): Use delete instead of
index 34182e050ab123dab68ce7937f767a5671d87189..7eed4f18454e6de10f43f980de31d082247bc2f6 100644 (file)
@@ -67,6 +67,6 @@ struct varobj_iter_ops
       if ((ITER) != NULL)                     \
        {                                      \
          (ITER)->ops->dtor (ITER);            \
-         delete (ITER);                       \
+         xfree (ITER);                \
        }                                      \
     } while (0)