[SERVER-4008] A memory leak per line of typed text in the shell Created: 04/Oct/11 Updated: 11/Jul/16 Resolved: 16/Nov/11 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Shell |
| Affects Version/s: | None |
| Fix Version/s: | 2.1.0 |
| Type: | Bug | Priority: | Minor - P4 |
| Reporter: | Tad Marshall | Assignee: | Tad Marshall |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Any |
||
| Operating System: | ALL |
| Participants: |
| Description |
|
The linenoise() routine that shell/dbshell.cpp calls to collect typed input from the user uses strdup() to make a copy of its internal buffer's contents and returns the pointer from strdup(). The calling code acts as if this is just a pointer it can play with and not a block of memory that it now owns. It never calls free() on it. After ten lines of typing, ten small buffers have been leaked. The buffers are the minimum size required to hold the text (e.g. "a=7" is 4 bytes) so the shell would need to have a novella typed into it for this to even begin to matter. This is user input only, displayed data does not leak. |
| Comments |
| Comment by Tad Marshall [ 16/Nov/11 ] |
|
Fixed in commit 8d8b272225b9a2e98f25525e0e2e7f032420388f ( |
| Comment by auto [ 16/Nov/11 ] |
|
Author: {u'login': u'', u'name': u'Tad Marshall', u'email': u'tad@10gen.com'}Message: Track the strdup-ed (i.e. malloc-ed) strings returned by linenoise, and |
| Comment by Tad Marshall [ 06/Oct/11 ] |
|
Pull request https://github.com/mongodb/mongo/pull/97 addresses this. |