From mboxrd@z Thu Jan 1 00:00:00 1970 From: bugzilla-daemon@freedesktop.org Subject: [Bug 108381] amdgpu_bo_import and amdgpu_bo_free are not paired which leaks amdgpu_bo Date: Tue, 16 Oct 2018 05:11:55 +0000 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1547799303==" Return-path: Received: from culpepper.freedesktop.org (culpepper.freedesktop.org [IPv6:2610:10:20:722:a800:ff:fe98:4b55]) by gabe.freedesktop.org (Postfix) with ESMTP id 0A1776E191 for ; Tue, 16 Oct 2018 05:11:56 +0000 (UTC) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" To: dri-devel@lists.freedesktop.org List-Id: dri-devel@lists.freedesktop.org --===============1547799303== Content-Type: multipart/alternative; boundary="15396667150.77c960cA.10656" Content-Transfer-Encoding: 7bit --15396667150.77c960cA.10656 Date: Tue, 16 Oct 2018 05:11:55 +0000 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://bugs.freedesktop.org/ Auto-Submitted: auto-generated https://bugs.freedesktop.org/show_bug.cgi?id=3D108381 Bug ID: 108381 Summary: amdgpu_bo_import and amdgpu_bo_free are not paired which leaks amdgpu_bo Product: Mesa Version: 18.2 Hardware: All OS: Linux (All) Status: NEW Severity: major Priority: medium Component: Drivers/Gallium/radeonsi Assignee: dri-devel@lists.freedesktop.org Reporter: zhangyong@lbesec.com QA Contact: dri-devel@lists.freedesktop.org Created attachment 142039 --> https://bugs.freedesktop.org/attachment.cgi?id=3D142039&action=3Dedit sample code to reproduce the issue amdgpu_bo is reference counted, libdrm expects the number of calls to amdgpu_bo_import must be equal to amdgpu_bo_free. When importing prime fd into mesa, amdgpu_bo_from_handle will be called, wh= ich calls amdgpu_bo_import to get the unique handle (which in fact is a pointer= to amdgpu_bo), then wrapped into amdgpu_winsys_bo object. The problem is amdgpu_winsys_bo is also reference counted, if one tries to import the same prime fd for multiple times, amdgpu_bo_import will be called for multiple times, but only one amdgpu_winsys_bo will be created, so amdgpu_bo_free will be called for only once, eventually leaks memory. I have attached a sample code to reproduce this issue. a possible solution is to call amdgpu_bo_free after amdgpu_bo_import if result.buf_handle can be found in ws->bo_export_table, which will balance t= he number of calls to amdgpu_bo_import and amdgpu_bo_free. --=20 You are receiving this mail because: You are the assignee for the bug.= --15396667150.77c960cA.10656 Date: Tue, 16 Oct 2018 05:11:55 +0000 MIME-Version: 1.0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://bugs.freedesktop.org/ Auto-Submitted: auto-generated
Bug ID 108381
Summary amdgpu_bo_import and amdgpu_bo_free are not paired which leak= s amdgpu_bo
Product Mesa
Version 18.2
Hardware All
OS Linux (All)
Status NEW
Severity major
Priority medium
Component Drivers/Gallium/radeonsi
Assignee dri-devel@lists.freedesktop.org
Reporter zhangyong@lbesec.com
QA Contact dri-devel@lists.freedesktop.org

Created attac=
hment 142039 [details]
sample code to reproduce the issue

amdgpu_bo is reference counted, libdrm expects the number of calls to
amdgpu_bo_import must be equal to amdgpu_bo_free.

When importing prime fd into mesa, amdgpu_bo_from_handle will be called, wh=
ich
calls amdgpu_bo_import to get the unique handle (which in fact is a pointer=
 to
amdgpu_bo), then wrapped into amdgpu_winsys_bo object.

The problem is amdgpu_winsys_bo is also reference counted, if one tries to
import the same prime fd for multiple times, amdgpu_bo_import will be called
for multiple times, but only one amdgpu_winsys_bo will be created, so
amdgpu_bo_free will be called for only once, eventually leaks memory.

I have attached a sample code to reproduce this issue.

a possible solution is to call amdgpu_bo_free after amdgpu_bo_import if
result.buf_handle can be found in ws->bo_export_table, which will balanc=
e the
number of calls to amdgpu_bo_import and amdgpu_bo_free.


You are receiving this mail because:
  • You are the assignee for the bug.
= --15396667150.77c960cA.10656-- --===============1547799303== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KZHJpLWRldmVs IG1haWxpbmcgbGlzdApkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnCmh0dHBzOi8vbGlz dHMuZnJlZWRlc2t0b3Aub3JnL21haWxtYW4vbGlzdGluZm8vZHJpLWRldmVsCg== --===============1547799303==--