Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5122

Fix memory leak in c_glib tutorial server

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 0.13.0
    • Fix Version/s: 0.14.0
    • Component/s: Tutorial
    • Labels:
      None
    • Flags:
      Patch

      Description

      The memory leak was triggered on running c_glib tutorial server. The memory used by a ThriftStruct's properties don't need to call g_strdup and will be malloced on set property. And the error object need to be freed.

      Leak:
      Direct leak of 19 byte(s) in 1 object(s) allocated from:
      #0 0x7f1744030ae8 in __interceptor_malloc (/usr/lib64/libasan.so.5+0xefae8)
      #1 0x7f17430851d5 in g_malloc (/usr/lib64/libglib-2.0.so.0+0x531d5)
      #2 0x7f174309eb32 in g_strdup (/usr/lib64/libglib-2.0.so.0+0x6cb32)
      #3 0x403285 in tutorial_calculator_handler_calculate /mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/c_glib_server.c:233
      #4 0x4081e4 in calculator_handler_calculate gen-c_glib/calculator.c:713
      #5 0x409870 in calculator_processor_process_calculate gen-c_glib/calculator.c:1030
      #6 0x40a483 in calculator_processor_dispatch_call gen-c_glib/calculator.c:1198
      #7 0x7f1743d1ee53 in thrift_dispatch_processor_process (/usr/lib64/libthrift_c_glib.so.0+0xee53)
      #8 0x7f1743d32d11 in thrift_simple_server_serve src/thrift/c_glib/server/thrift_simple_server.c:58
      #9 0x7f1743d31b9a in thrift_server_serve src/thrift/c_glib/server/thrift_server.c:108
      #10 0x404113 in main /mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/c_glib_server.c:506
      #11 0x7f1742869872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
      #12 0x402a0d in _start (/mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/.libs/tutorial_server+0x402a0d)

      Direct leak of 16 byte(s) in 1 object(s) allocated from:
      #0 0x7f1744030ae8 in __interceptor_malloc (/usr/lib64/libasan.so.5+0xefae8)
      #1 0x7f17430851d5 in g_malloc (/usr/lib64/libglib-2.0.so.0+0x531d5)
      #2 0x7f174309ce06 in g_slice_alloc (/usr/lib64/libglib-2.0.so.0+0x6ae06)
      #3 0x7f174306a350 in g_error_new_valist (/usr/lib64/libglib-2.0.so.0+0x38350)
      #4 0x7f174306a75e in g_set_error (/usr/lib64/libglib-2.0.so.0+0x3875e)
      #5 0x7f1743d2df8e in thrift_server_socket_accept src/thrift/c_glib/transport/thrift_server_socket.c:147
      #6 0x7f1743d2d17d in thrift_server_transport_accept (/usr/lib64/libthrift_c_glib.so.0+0x1d17d)
      #7 0x7f1743d3298a in thrift_simple_server_serve src/thrift/c_glib/server/thrift_simple_server.c:42
      #8 0x7f1743d31b9a in thrift_server_serve src/thrift/c_glib/server/thrift_server.c:108
      #9 0x404113 in main /mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/c_glib_server.c:506
      #10 0x7f1742869872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
      #11 0x402a0d in _start (/mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/.libs/tutorial_server+0x402a0d)

      Direct leak of 2 byte(s) in 1 object(s) allocated from:
      #0 0x7f1744030ae8 in __interceptor_malloc (/usr/lib64/libasan.so.5+0xefae8)
      #1 0x7f17430851d5 in g_malloc (/usr/lib64/libglib-2.0.so.0+0x531d5)
      #2 0x7f174309eb32 in g_strdup (/usr/lib64/libglib-2.0.so.0+0x6cb32)
      #3 0x403569 in tutorial_calculator_handler_calculate /mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/c_glib_server.c:265
      #4 0x4081e4 in calculator_handler_calculate gen-c_glib/calculator.c:713
      #5 0x409870 in calculator_processor_process_calculate gen-c_glib/calculator.c:1030
      #6 0x40a483 in calculator_processor_dispatch_call gen-c_glib/calculator.c:1198
      #7 0x7f1743d1ee53 in thrift_dispatch_processor_process (/usr/lib64/libthrift_c_glib.so.0+0xee53)
      #8 0x7f1743d32d11 in thrift_simple_server_serve src/thrift/c_glib/server/thrift_simple_server.c:58
      #9 0x7f1743d31b9a in thrift_server_serve src/thrift/c_glib/server/thrift_server.c:108
      #10 0x404113 in main /mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/c_glib_server.c:506
      #11 0x7f1742869872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
      #12 0x402a0d in _start (/mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/.libs/tutorial_server+0x402a0d)

      Direct leak of 2 byte(s) in 1 object(s) allocated from:
      #0 0x7f1744030ae8 in __interceptor_malloc (/usr/lib64/libasan.so.5+0xefae8)
      #1 0x7f17430851d5 in g_malloc (/usr/lib64/libglib-2.0.so.0+0x531d5)
      #2 0x7f174309eb32 in g_strdup (/usr/lib64/libglib-2.0.so.0+0x6cb32)
      #3 0x7f1743af773c (/usr/lib64/libgobject-2.0.so.0+0x3a73c)
      #4 0x7f1743ad60a5 in g_object_get_valist (/usr/lib64/libgobject-2.0.so.0+0x190a5)
      #5 0x7f1743ad6463 in g_object_get (/usr/lib64/libgobject-2.0.so.0+0x19463)
      #6 0x403a2b in tutorial_calculator_handler_get_struct /mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/c_glib_server.c:333
      #7 0x40c76c in shared_service_handler_get_struct gen-c_glib/shared_service.c:325
      #8 0x40cc0d in shared_service_processor_process_get_struct gen-c_glib/shared_service.c:416
      #9 0x40d1f5 in shared_service_processor_dispatch_call gen-c_glib/shared_service.c:498
      #10 0x40a4d4 in calculator_processor_dispatch_call gen-c_glib/calculator.c:1206
      #11 0x7f1743d1ee53 in thrift_dispatch_processor_process (/usr/lib64/libthrift_c_glib.so.0+0xee53)
      #12 0x7f1743d32d11 in thrift_simple_server_serve src/thrift/c_glib/server/thrift_simple_server.c:58
      #13 0x7f1743d31b9a in thrift_server_serve src/thrift/c_glib/server/thrift_server.c:108
      #14 0x404113 in main /mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/c_glib_server.c:506
      #15 0x7f1742869872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
      #16 0x402a0d in _start (/mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/.libs/tutorial_server+0x402a0d)

      Direct leak of 2 byte(s) in 1 object(s) allocated from:
      #0 0x7f1744030ae8 in __interceptor_malloc (/usr/lib64/libasan.so.5+0xefae8)
      #1 0x7f17430851d5 in g_malloc (/usr/lib64/libglib-2.0.so.0+0x531d5)
      #2 0x7f174309eb32 in g_strdup (/usr/lib64/libglib-2.0.so.0+0x6cb32)
      #3 0x403a5a in tutorial_calculator_handler_get_struct /mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/c_glib_server.c:337
      #4 0x40c76c in shared_service_handler_get_struct gen-c_glib/shared_service.c:325
      #5 0x40cc0d in shared_service_processor_process_get_struct gen-c_glib/shared_service.c:416
      #6 0x40d1f5 in shared_service_processor_dispatch_call gen-c_glib/shared_service.c:498
      #7 0x40a4d4 in calculator_processor_dispatch_call gen-c_glib/calculator.c:1206
      #8 0x7f1743d1ee53 in thrift_dispatch_processor_process (/usr/lib64/libthrift_c_glib.so.0+0xee53)
      #9 0x7f1743d32d11 in thrift_simple_server_serve src/thrift/c_glib/server/thrift_simple_server.c:58
      #10 0x7f1743d31b9a in thrift_server_serve src/thrift/c_glib/server/thrift_server.c:108
      #11 0x404113 in main /mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/c_glib_server.c:506
      #12 0x7f1742869872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
      #13 0x402a0d in _start (/mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/.libs/tutorial_server+0x402a0d)

      Indirect leak of 54 byte(s) in 1 object(s) allocated from:
      #0 0x7f1744030f28 in __interceptor_realloc (/usr/lib64/libasan.so.5+0xeff28)
      #1 0x7f17429537d9 in _GI__vasprintf_chk (/usr/lib64/libc.so.6+0x10d7d9)
      #2 0x7f17430c5a6c in g_vasprintf (/usr/lib64/libglib-2.0.so.0+0x93a6c)
      #3 0x7f174309ecd0 in g_strdup_vprintf (/usr/lib64/libglib-2.0.so.0+0x6ccd0)
      #4 0x7f174306a365 in g_error_new_valist (/usr/lib64/libglib-2.0.so.0+0x38365)
      #5 0x7f174306a75e in g_set_error (/usr/lib64/libglib-2.0.so.0+0x3875e)
      #6 0x7f1743d2df8e in thrift_server_socket_accept src/thrift/c_glib/transport/thrift_server_socket.c:147
      #7 0x7f1743d2d17d in thrift_server_transport_accept (/usr/lib64/libthrift_c_glib.so.0+0x1d17d)
      #8 0x7f1743d3298a in thrift_simple_server_serve src/thrift/c_glib/server/thrift_simple_server.c:42
      #9 0x7f1743d31b9a in thrift_server_serve src/thrift/c_glib/server/thrift_server.c:108
      #10 0x404113 in main /mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/c_glib_server.c:506
      #11 0x7f1742869872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
      #12 0x402a0d in _start (/mnt/hgfs/share/thrift-0.13.0/tutorial/c_glib/.libs/tutorial_server+0x402a0d)

       

        Attachments

          Activity

            People

            • Assignee:
              wangyunjian wangyunjian
              Reporter:
              wangyunjian wangyunjian
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 2.5h
                2.5h