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

Fix memory leak in thrift_multiplexed_processor_process_impl()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • None
    • 0.14.0
    • C glib - Library
    • None
    • Patch

    Description

      The memory leak was triggered on calling thrift_multiplexed_processor_process_impl().
      The variable stored_message_protocol has been malloced, but it hasn't been freed.
      Release it directly, there will be other problems. The reason for the problems is that
      it will double free fname. The stored message protocol should copy the fname, so we can
      free it.

      Leak:
      Direct leak of 1848 byte(s) in 33 object(s) allocated from:
      #0 0x7f2d37eb7ae8 in __interceptor_malloc (/usr/lib64/libasan.so.5+0xefae8)
      #1 0x7f2d36ee61d5 in g_malloc (/usr/lib64/libglib-2.0.so.0+0x531d5)
      #2 0x7f2d36efde06 in g_slice_alloc (/usr/lib64/libglib-2.0.so.0+0x6ae06)
      #3 0x7f2d36efe44c in g_slice_alloc0 (/usr/lib64/libglib-2.0.so.0+0x6b44c)
      #4 0x7f2d37951849 in g_type_create_instance gtype.c:1848
      #5 0x7f2d37933fc7 in g_object_new_internal gobject.c:1799
      #6 0x7f2d37935f4d in g_object_new_valist (/usr/lib64/libgobject-2.0.so.0+0x17f4d)
      #7 0x7f2d379362ac in g_object_new (/usr/lib64/libgobject-2.0.so.0+0x182ac)
      #8 0x7f2d37b8a1b6 in thrift_multiplexed_processor_process_impl src/thrift/c_glib/processor/thrift_multiplexed_processor.c:138
      #9 0x7f2d37bad7bb in thrift_simple_server_serve src/thrift/c_glib/server/thrift_simple_server.c:58
      #10 0x7f2d37bac644 in thrift_server_serve src/thrift/c_glib/server/thrift_server.c:108
      #11 0x409341 in main src/test_server.c:278
      #12 0x7f2d366ca872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
      #13 0x404a1d in _start (/mnt/hgfs/share/thrift-0.13.0/test/c_glib/.libs/lt-test_server+0x404a1d)

      Indirect leak of 256 byte(s) in 1 object(s) allocated from:
      #0 0x7f2d37eb7f28 in __interceptor_realloc (/usr/lib64/libasan.so.5+0xeff28)
      #1 0x7f2d36ee628d in g_realloc (/usr/lib64/libglib-2.0.so.0+0x5328d)
      #2 0x7f2d36eb1728 in g_array_maybe_expand garray.c:794
      #3 0x7f2d36eb1ae9 in g_array_append_vals (/usr/lib64/libglib-2.0.so.0+0x1eae9)
      #4 0x7f2d36eb2e0c in g_byte_array_append (/usr/lib64/libglib-2.0.so.0+0x1fe0c)
      #5 0x7f2d37ba7068 in thrift_buffered_transport_read_slow src/thrift/c_glib/transport/thrift_buffered_transport.c:122
      #6 0x7f2d37ba729e in thrift_buffered_transport_read src/thrift/c_glib/transport/thrift_buffered_transport.c:152
      #7 0x7f2d37b9f9e4 in thrift_transport_real_read_all src/thrift/c_glib/transport/thrift_transport.c:122
      #8 0x7f2d37b9f8cd in thrift_transport_read_all src/thrift/c_glib/transport/thrift_transport.c:92
      #9 0x7f2d37b957a6 in thrift_binary_protocol_read_binary src/thrift/c_glib/protocol/thrift_binary_protocol.c:841
      #10 0x7f2d37b8fc1b in thrift_protocol_decorator_read_binary src/thrift/c_glib/protocol/thrift_protocol_decorator.c:477
      #11 0x7f2d37b8c4b2 in thrift_protocol_read_binary src/thrift/c_glib/protocol/thrift_protocol.c:418
      #12 0x4740ca in t_test_thrift_test_test_binary_args_read gen-c_glib/t_test_thrift_test_types.c:13562
      #13 0x7f2d37b87865 in thrift_struct_read src/thrift/c_glib/thrift_struct.c:30
      #14 0x42c257 in t_test_thrift_test_processor_process_test_binary gen-c_glib/t_test_thrift_test.c:5665
      #15 0x43412c in t_test_thrift_test_processor_dispatch_call gen-c_glib/t_test_thrift_test.c:7178
      #16 0x7f2d37b892f0 in thrift_dispatch_processor_process src/thrift/c_glib/processor/thrift_dispatch_processor.c:56
      #17 0x7f2d37b8a250 in thrift_multiplexed_processor_process_impl src/thrift/c_glib/processor/thrift_multiplexed_processor.c:149
      #18 0x7f2d37bad7bb in thrift_simple_server_serve src/thrift/c_glib/server/thrift_simple_server.c:58
      #19 0x7f2d37bac644 in thrift_server_serve src/thrift/c_glib/server/thrift_server.c:108
      #20 0x409341 in main src/test_server.c:278
      #21 0x7f2d366ca872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
      #22 0x404a1d in _start (/mnt/hgfs/share/thrift-0.13.0/test/c_glib/.libs/lt-test_server+0x404a1d)

      Indirect leak of 56 byte(s) in 1 object(s) allocated from:
      #0 0x7f2d37eb7ae8 in __interceptor_malloc (/usr/lib64/libasan.so.5+0xefae8)
      #1 0x7f2d36ee61d5 in g_malloc (/usr/lib64/libglib-2.0.so.0+0x531d5)
      #2 0x7f2d36efde06 in g_slice_alloc (/usr/lib64/libglib-2.0.so.0+0x6ae06)
      #3 0x7f2d36efe44c in g_slice_alloc0 (/usr/lib64/libglib-2.0.so.0+0x6b44c)
      #4 0x7f2d37951849 in g_type_create_instance gtype.c:1848
      #5 0x7f2d37933fc7 in g_object_new_internal gobject.c:1799
      #6 0x7f2d37935f4d in g_object_new_valist (/usr/lib64/libgobject-2.0.so.0+0x17f4d)
      #7 0x7f2d379362ac in g_object_new (/usr/lib64/libgobject-2.0.so.0+0x182ac)
      #8 0x7f2d37b9ff3f in thrift_buffered_transport_factory_get_transport src/thrift/c_glib/transport/thrift_buffered_transport_factory.c:35
      #9 0x7f2d37bad52c in thrift_simple_server_serve src/thrift/c_glib/server/thrift_simple_server.c:46
      #10 0x7f2d37bac644 in thrift_server_serve src/thrift/c_glib/server/thrift_server.c:108
      #11 0x409341 in main src/test_server.c:278
      #12 0x7f2d366ca872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
      #13 0x404a1d in _start (/mnt/hgfs/share/thrift-0.13.0/test/c_glib/.libs/lt-test_server+0x404a1d)

      Indirect leak of 40 byte(s) in 1 object(s) allocated from:
      #0 0x7f2d37eb7ae8 in __interceptor_malloc (/usr/lib64/libasan.so.5+0xefae8)
      #1 0x7f2d36ee61d5 in g_malloc (/usr/lib64/libglib-2.0.so.0+0x531d5)
      #2 0x7f2d36efde06 in g_slice_alloc (/usr/lib64/libglib-2.0.so.0+0x6ae06)
      #3 0x7f2d36eb1894 in g_array_sized_new (/usr/lib64/libglib-2.0.so.0+0x1e894)
      #4 0x7f2d37ba7cf7 in thrift_buffered_transport_init src/thrift/c_glib/transport/thrift_buffered_transport.c:266
      #5 0x7f2d379518e9 in g_type_create_instance gtype.c:1866
      #6 0x7f2d37933fc7 in g_object_new_internal gobject.c:1799
      #7 0x7f2d37935f4d in g_object_new_valist (/usr/lib64/libgobject-2.0.so.0+0x17f4d)
      #8 0x7f2d379362ac in g_object_new (/usr/lib64/libgobject-2.0.so.0+0x182ac)
      #9 0x7f2d37b9ff3f in thrift_buffered_transport_factory_get_transport src/thrift/c_glib/transport/thrift_buffered_transport_factory.c:35
      #10 0x7f2d37bad52c in thrift_simple_server_serve src/thrift/c_glib/server/thrift_simple_server.c:46
      #11 0x7f2d37bac644 in thrift_server_serve src/thrift/c_glib/server/thrift_server.c:108
      #12 0x409341 in main src/test_server.c:278
      #13 0x7f2d366ca872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
      #14 0x404a1d in _start (/mnt/hgfs/share/thrift-0.13.0/test/c_glib/.libs/lt-test_server+0x404a1d)

      Indirect leak of 40 byte(s) in 1 object(s) allocated from:
      #0 0x7f2d37eb7ae8 in __interceptor_malloc (/usr/lib64/libasan.so.5+0xefae8)
      #1 0x7f2d36ee61d5 in g_malloc (/usr/lib64/libglib-2.0.so.0+0x531d5)
      #2 0x7f2d36efde06 in g_slice_alloc (/usr/lib64/libglib-2.0.so.0+0x6ae06)
      #3 0x7f2d36eb1894 in g_array_sized_new (/usr/lib64/libglib-2.0.so.0+0x1e894)
      #4 0x7f2d37ba7d2c in thrift_buffered_transport_init src/thrift/c_glib/transport/thrift_buffered_transport.c:267
      #5 0x7f2d379518e9 in g_type_create_instance gtype.c:1866
      #6 0x7f2d37933fc7 in g_object_new_internal gobject.c:1799
      #7 0x7f2d37935f4d in g_object_new_valist (/usr/lib64/libgobject-2.0.so.0+0x17f4d)
      #8 0x7f2d379362ac in g_object_new (/usr/lib64/libgobject-2.0.so.0+0x182ac)
      #9 0x7f2d37b9ff3f in thrift_buffered_transport_factory_get_transport src/thrift/c_glib/transport/thrift_buffered_transport_factory.c:35
      #10 0x7f2d37bad52c in thrift_simple_server_serve src/thrift/c_glib/server/thrift_simple_server.c:46
      #11 0x7f2d37bac644 in thrift_server_serve src/thrift/c_glib/server/thrift_server.c:108
      #12 0x409341 in main src/test_server.c:278
      #13 0x7f2d366ca872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
      #14 0x404a1d in _start (/mnt/hgfs/share/thrift-0.13.0/test/c_glib/.libs/lt-test_server+0x404a1d)

      Indirect leak of 32 byte(s) in 1 object(s) allocated from:
      #0 0x7f2d37eb7ae8 in __interceptor_malloc (/usr/lib64/libasan.so.5+0xefae8)
      #1 0x7f2d36ee61d5 in g_malloc (/usr/lib64/libglib-2.0.so.0+0x531d5)
      #2 0x7f2d36efde06 in g_slice_alloc (/usr/lib64/libglib-2.0.so.0+0x6ae06)
      #3 0x7f2d36efe44c in g_slice_alloc0 (/usr/lib64/libglib-2.0.so.0+0x6b44c)
      #4 0x7f2d37951849 in g_type_create_instance gtype.c:1848
      #5 0x7f2d37933fc7 in g_object_new_internal gobject.c:1799
      #6 0x7f2d37935f4d in g_object_new_valist (/usr/lib64/libgobject-2.0.so.0+0x17f4d)
      #7 0x7f2d379362ac in g_object_new (/usr/lib64/libgobject-2.0.so.0+0x182ac)
      #8 0x7f2d37b979b8 in thrift_binary_protocol_factory_get_protocol src/thrift/c_glib/protocol/thrift_binary_protocol_factory.c:30
      #9 0x7f2d37bad670 in thrift_simple_server_serve src/thrift/c_glib/server/thrift_simple_server.c:52
      #10 0x7f2d37bac644 in thrift_server_serve src/thrift/c_glib/server/thrift_server.c:108
      #11 0x409341 in main src/test_server.c:278
      #12 0x7f2d366ca872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
      #13 0x404a1d in _start (/mnt/hgfs/share/thrift-0.13.0/test/c_glib/.libs/lt-test_server+0x404a1d)

      Attachments

        Issue Links

          Activity

            People

              wangyunjian wangyunjian
              wangyunjian wangyunjian
              Votes:
              0 Vote for this issue
              Watchers:
              3 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 - 1h 20m
                  1h 20m