2018-04-21 12:54 BST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0002579NetSurf[All Projects] Generalpublic2018-01-20 16:20
ReporterFelix S. 
Assigned To 
SeverityminorReproducibilityalways 
StatusresolvedResolutionfixed 
Product Version3.7 
Target Version3.8Fixed in Version3.8 
Summary0002579: Memory leak in a cache back-end
DescriptionThere is a memory leak in cache code. Two allocations made in the file system backend (content/fs_backing_store.c) are apparently never disposed of: one in read_entries() and one in build_entrymap().
Steps To ReproduceThis problem should be possible to detect with any memory leak detection tool. (The particular tool used to write this report was memtrail[0], chosen mainly for its low instrumentation overhead.)

[0]: <https://github.com/jrfonseca/memtrail/>
Additional InformationFragment of the output of memtrail report:

leaked: 9,425,771B
  -> 64.22% (6,053,352B): calloc
  | -> 27.81% (2,621,440B): read_entries [./netsurf/content/fs_backing_store.c:1230]
  | | -> 27.81% (2,621,440B): hlcache_initialise [./netsurf/content/hlcache.c:535]
  | | -> 27.81% (2,621,440B): netsurf_init [./netsurf/desktop/netsurf.c:226]
  | | -> 27.81% (2,621,440B): main [./netsurf/frontends/gtk/gui.c:1178]
  | | -> 27.81% (2,621,440B): __libc_start_main [/build/glibc-mcIJEN/glibc-2.25/csu/../csu/libc-start.c:297]
  | | -> 27.81% (2,621,440B): _start
  | |
  | -> 22.25% (2,097,152B): build_entrymap [./netsurf/content/fs_backing_store.c:1148]
  | | -> 22.25% (2,097,152B): hlcache_initialise [./netsurf/content/hlcache.c:535]
  | | -> 22.25% (2,097,152B): netsurf_init [./netsurf/desktop/netsurf.c:226]
  | | -> 22.25% (2,097,152B): main [./netsurf/frontends/gtk/gui.c:1178]
  | | -> 22.25% (2,097,152B): __libc_start_main [/build/glibc-mcIJEN/glibc-2.25/csu/../csu/libc-start.c:297]
  | | -> 22.25% (2,097,152B): _start
  | |
...

Attached patch seems to fix the problem.
TagsNo tags attached.
Fixed in CI build #4292
Reported in CI build #
URL of problem page
Attached Files
  • patch file icon netsurf-cache-memleak.patch (794 bytes) 2017-12-06 14:38 -
    --- a/content/fs_backing_store.c
    +++ b/content/fs_backing_store.c
    @@ -1565,6 +1565,7 @@ initialise(const struct llcache_store_parameters *parameters)
     	ret = build_entrymap(newstate);
     	if (ret != NSERROR_OK) {
     		/* that obviously went well */
    +		free(newstate->entries);
     		free(newstate->path);
     		free(newstate);
     		return ret;
    @@ -1573,6 +1574,8 @@ initialise(const struct llcache_store_parameters *parameters)
     	ret = read_blocks(newstate);
     	if (ret != NSERROR_OK) {
     		/* oh dear */
    +		free(newstate->addrmap);
    +		free(newstate->entries);
     		free(newstate->path);
     		free(newstate);
     		return ret;
    @@ -1640,6 +1643,8 @@ finalise(void)
     			      0);
     		}
     
    +		free(storestate->addrmap);
    +		free(storestate->entries);
     		free(storestate->path);
     		free(storestate);
     		storestate = NULL;
    
    patch file icon netsurf-cache-memleak.patch (794 bytes) 2017-12-06 14:38 +

-Relationships
+Relationships

-Notes
John-Mark Bell

~0001707

John-Mark Bell (administrator)

Thanks for the report. Patch applied in master.
+Notes

-Issue History
Date Modified Username Field Change
2017-12-06 14:38 Felix S. New Issue
2017-12-06 14:38 Felix S. File Added: netsurf-cache-memleak.patch
2018-01-20 16:20 John-Mark Bell Status new => resolved
2018-01-20 16:20 John-Mark Bell Resolution open => fixed
2018-01-20 16:20 John-Mark Bell Fixed in Version => 3.8
2018-01-20 16:20 John-Mark Bell Target Version => 3.8
2018-01-20 16:20 John-Mark Bell Steps to Reproduce Updated View Revisions
2018-01-20 16:20 John-Mark Bell Additional Information Updated View Revisions
2018-01-20 16:20 John-Mark Bell Fixed in CI build # => 4292
2018-01-20 16:20 John-Mark Bell Note Added: 0001707
+Issue History