Bug 93625 - Memory leaks in backend/src/gbe_bin_generater.cpp when building beignet
Summary: Memory leaks in backend/src/gbe_bin_generater.cpp when building beignet
Status: RESOLVED FIXED
Alias: None
Product: Beignet
Classification: Unclassified
Component: Beignet (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Xiuli Pan
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-01-07 12:16 UTC by Frank Dittrich
Modified: 2016-05-10 08:32 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description Frank Dittrich 2016-01-07 12:16:50 UTC
The following patch is needed to fix memory leaks when building beignet, e.g., if you want to build beignet with -fsanitize=address.

diff --git a/backend/src/gbe_bin_generater.cpp b/backend/src/gbe_bin_generater.cpp
index 8225d4a..7ed353a 100644
--- a/backend/src/gbe_bin_generater.cpp
+++ b/backend/src/gbe_bin_generater.cpp
@@ -226,6 +226,7 @@ void program_build_instance::serialize_program(void) throw(int)
         size_t bin_length = gbe_program_serialize_to_binary((gbe_program)gbe_prog, &llvm_binary, 1);
         oss.write(llvm_binary, bin_length);
         sz += bin_length;
+        free(llvm_binary);
       }
 
       for (size_t i = 0; i < sz; i++) {
@@ -258,6 +259,7 @@ void program_build_instance::serialize_program(void) throw(int)
         size_t bin_length = gbe_program_serialize_to_binary((gbe_program)gbe_prog, &llvm_binary, 1);
         ofs.write(llvm_binary, bin_length);
         sz+=bin_length;
+        free(llvm_binary);
       }
     }
Comment 1 rongyang 2016-04-29 02:40:08 UTC
Thanks for you patch, it looks good to me.
Can you use send the patch(using command git format-patch -s) to mailing list.
Comment 2 Xiuli Pan 2016-05-05 06:43:45 UTC
Hi Frank,

I have help you send a patch to the maillist:
https://lists.freedesktop.org/archives/beignet/2016-May/007507.html
Hope you don't mind that.

Thanks
Xiuli
Comment 3 Frank Dittrich 2016-05-05 09:00:32 UTC
Hi Xiuli,

no problem, thanks.
I was just extremely busy, otherwise I would have sent that patch to the mailing list.
Comment 4 Xiuli Pan 2016-05-10 08:32:51 UTC
Hi Frank,

Then I will close this bug, and I have send patches for your other two bugs. You can have a look at them.

Thanks
Xiuli


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.