Skip to content

Memory leak in fwrite #6733

@aitap

Description

@aitap

Found while testing the fix for #6731.

Setting aside the leaks from zlib and fontconfig, we've got the following for tests/main.R:

Direct leak of 125829120 byte(s) in 15 object(s) allocated from:
    #1 0x7f43e5ea224a in fwriteMain src/fwrite.c:792
    #2 0x7f43e5ea7638 in fwriteR src/fwriteR.c:310

plus a few tens of megabytes from other objects allocated in the same place.

Looks like this allocation:

char *buffPool = malloc(alloc_size);

are not always matched with this deallocation:
free(buffPool);

(Some allocations done internally by zlib are also leaks, but LeakSanitizer doesn't trace them to a specific line in data.table.)

We've got quite a few calls to STOP() between the two lines, and most of those don't release the memory allocated for buffPool. This bisects to e0abdfc, i.e., #6393. Before this commit, tests/main.R finishes without any notes from LeakSanitizer.

Edit: the title used to say "leak in fread", which was not correct at all.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions