[
https://issues.apache.org/jira/browse/THRIFT-5144?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Jens Geyer resolved THRIFT-5144.
--------------------------------
Fix Version/s: 0.14.0
Resolution: Fixed
> Fix memory leak when generate deserialize list element
> ------------------------------------------------------
>
> Key: THRIFT-5144
> URL: https://issues.apache.org/jira/browse/THRIFT-5144
> Project: Thrift
> Issue Type: Bug
> Components: C glib - Compiler
> Affects Versions: 0.13.0
> Reporter: wangyunjian
> Assignee: wangyunjian
> Priority: Critical
> Fix For: 0.14.0
>
> Time Spent: 50m
> Remaining Estimate: 0h
>
> The memory leak was triggered on calling generate_deserialize_list_element()
> function when the elements's type is numeric.The memory leak was triggered on
> calling generate_deserialize_list_element() function when the elements's type
> is numeric. The elements have been malloced, but they have not been freed.
> The elements need to be freed after adding in array.
> Leak:
> Direct leak of 20 byte(s) in 5 object(s) allocated from:
> #0 0x7f0d7e5adae8 in __interceptor_malloc
> (/usr/lib64/libasan.so.5+0xefae8)
> #1 0x7f0d7d5dc1d5 in g_malloc (/usr/lib64/libglib-2.0.so.0+0x531d5)
> #2 0x427d91 in t_test_thrift_test_client_recv_test_list
> gen-c_glib/t_test_thrift_test.c:2845
> #3 0x42827c in t_test_thrift_test_client_test_list
> gen-c_glib/t_test_thrift_test.c:2891
> #4 0x417f68 in t_test_thrift_test_if_test_list
> gen-c_glib/t_test_thrift_test.c:93
> #5 0x40eb74 in main src/test_client.c:1048
> #6 0x7f0d7cdc0872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
> #7 0x404e4d in _start
> (/mnt/hgfs/share/thrift-0.13.0/test/c_glib/.libs/test_client+0x404e4d)
> Direct leak of 20 byte(s) in 5 object(s) allocated from:
> #0 0x7f6e884a0ae8 in __interceptor_malloc
> (/usr/lib64/libasan.so.5+0xefae8)
> #1 0x7f6e874cf1d5 in g_malloc (/usr/lib64/libglib-2.0.so.0+0x531d5)
> #2 0x482e86 in t_test_thrift_test_test_list_args_read
> gen-c_glib/t_test_thrift_test_types.c:16790
> #3 0x7f6e88170865 in thrift_struct_read
> src/thrift/c_glib/thrift_struct.c:30
> #4 0x42f3d1 in t_test_thrift_test_processor_process_test_list
> gen-c_glib/t_test_thrift_test.c:6253
> #5 0x4340fc in t_test_thrift_test_processor_dispatch_call
> gen-c_glib/t_test_thrift_test.c:7178
> #6 0x7f6e881722f0 in thrift_dispatch_processor_process
> src/thrift/c_glib/processor/thrift_dispatch_processor.c:56
> #7 0x7f6e881967df in thrift_simple_server_serve
> src/thrift/c_glib/server/thrift_simple_server.c:58
> #8 0x7f6e88195668 in thrift_server_serve
> src/thrift/c_glib/server/thrift_server.c:108
> #9 0x409311 in main src/test_server.c:278
> #10 0x7f6e86cb3872 in __libc_start_main (/usr/lib64/libc.so.6+0x23872)
> #11 0x4049ed in _start
> (/mnt/hgfs/share/thrift-0.13.0/test/c_glib/.libs/test_server+0x4049ed)
> The old code:
> /* iterate through list elements */
> for (i = 0; i < size; i++)
> {
> gint32* _elem31 = g_new (gint32, 1);
> if ((ret = thrift_protocol_read_i32 (protocol, &*_elem31, error)) < 0)
> return -1;
> xfer += ret;
> g_array_append_vals (this_object->newlist, _elem31, 1);
> }
> The new code:
> /* iterate through list elements */
> for (i = 0; i < size; i++)
> {
> gint32* _elem31 = g_new (gint32, 1);
> if ((ret = thrift_protocol_read_i32 (protocol, &*_elem31, error)) < 0)
> return -1;
> xfer += ret;
> g_array_append_vals (this_object->newlist, _elem31, 1);
> g_free (_elem31);
> }
--
This message was sent by Atlassian Jira
(v8.3.4#803005)