Bug 92339 - xosview port has a memory leak
Summary: xosview port has a memory leak
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Cheng-Lung Sung
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-26 02:40 UTC by pavel
Modified: 2006-01-27 08:18 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description pavel 2006-01-26 02:40:02 UTC
The sysutils/xosview port that comes with 6.0 results in a memory leak that eventually crashes the xosview process.  The CVS tree doesn't show any activity here more recent than 6.0.  The attached extra patch to bsd/kernel.cc fixes the problem.

Fix: 

+    // keep track of the mem we're given:
+    base_intrcnt = kvm_intrcnt;
+    base_intrname = kvm_intrname;
+
     safe_kvm_read (nlst[INTRCNT_SYM_INDEX].n_value, kvm_intrcnt, intrcntlen);
     safe_kvm_read (nlst[INTRNAMES_SYM_INDEX].n_value, kvm_intrname, inamlen);

@@ -1035,6 +1039,10 @@
        kvm_intrcnt++;
        kvm_intrname += strlen(kvm_intrname) + 1;
     }
+
+    // Doh! somebody needs to free this stuff too... (pavel 20-Jan-2006)
+    free(base_intrcnt);
+    free(base_intrname);
 #endif
 #elif defined (XOSVIEW_BSDI)
     int nintr = 16;--A60CKLRK1DhKadbiyt4A2Ej67DHW5kNl9hjerhPhLdExB1Of
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

--- work/xosview-1.8.2/bsd/kernel.cc.save       Thu Jan 19 14:26:39 2006
+++ work/xosview-1.8.2/bsd/kernel.cc    Fri Jan 20 16:35:35 2006
@@ -1006,8 +1006,8 @@
     }
 #else /* FreeBSD 5.x and 6.x */
     /* This code is stolen from vmstat */
-    unsigned long *kvm_intrcnt;
-    char *kvm_intrname;
+    unsigned long *kvm_intrcnt, *base_intrcnt;
+    char *kvm_intrname, *base_intrname;
     size_t inamlen, intrcntlen;
     unsigned int i, nintr;
     int d;
@@ -1020,6 +1020,10 @@
        ((kvm_intrname = (char *)malloc(inamlen)) == NULL))
       err(1, "malloc()");
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2006-01-26 11:14:32 UTC
Responsible Changed
From-To: freebsd-ports-bugs->clsung

Over to maintainer
Comment 2 Cheng-Lung Sung freebsd_committer freebsd_triage 2006-01-27 08:18:07 UTC
State Changed
From-To: open->closed

Committed. Thank You.