<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:58:10 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[SERVER-1827] Memory leak when there&apos;s multiple query plans with empty result</title>
                <link>https://jira.mongodb.org/browse/SERVER-1827</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;Steps to reproduce:&lt;br/&gt;
on empty DB do&lt;/p&gt;

&lt;p&gt;&amp;gt; db.tst.insert({_id: &quot;foo&quot;, k: &quot;bar&quot;})&lt;br/&gt;
&amp;gt; db.tst.find({$or: &lt;span class=&quot;error&quot;&gt;&amp;#91;{_id: &amp;quot;a&amp;quot;, k: &amp;quot;b&amp;quot;}, {_id: &amp;quot;c&amp;quot;,  k: &amp;quot;d&amp;quot;}&amp;#93;&lt;/span&gt;})&lt;/p&gt;

&lt;p&gt;Every such find() statement produces a leak of 32k bytes(see the very last record in attached valgrind log)&lt;/p&gt;

&lt;p&gt;The problem is that in UserQueryOp::finish(), when appending data to message, there&apos;s no check if data length is 0. Here&apos;s the code:&lt;br/&gt;
&amp;#8211; db/query.cpp@818&lt;br/&gt;
            if ( _pq.isExplain()) &lt;/p&gt;
{
                _eb.noteScan( _c.get(), _nscanned, _nscannedObjects, _n, scanAndOrderRequired(), _curop.elapsedMillis(), useHints &amp;amp;&amp;amp; !_pq.getHint().eoo() );
            }
&lt;p&gt; else &lt;/p&gt;
{
                _response.appendData( _buf.buf(), _buf.len() );
                _buf.decouple();
            }
&lt;p&gt;&amp;#8211;&lt;br/&gt;
In case when _buf.len() is 0, the _response doesn&apos;t take ownership over _buf data, so after calling _buf.decouple() allocated buffer is lost and will be never freed.&lt;/p&gt;

&lt;p&gt;I was able to reproduce this on 1.6.2 and git master, patch against master is attached.&lt;/p&gt;</description>
                <environment></environment>
        <key id="13147">SERVER-1827</key>
            <summary>Memory leak when there&apos;s multiple query plans with empty result</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="mathias@mongodb.com">Mathias Stearn</assignee>
                                    <reporter username="cverutin">Constantine Verutin</reporter>
                        <labels>
                    </labels>
                <created>Wed, 22 Sep 2010 13:00:09 +0000</created>
                <updated>Tue, 12 Jul 2016 00:20:33 +0000</updated>
                            <resolved>Tue, 26 Oct 2010 12:35:35 +0000</resolved>
                                    <version>1.6.2</version>
                                    <fixVersion>1.6.4</fixVersion>
                    <fixVersion>1.7.1</fixVersion>
                                    <component>Stability</component>
                                        <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="19668" author="auto" created="Tue, 26 Oct 2010 19:51:37 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;login&apos;: &apos;RedBeard0531&apos;, &apos;name&apos;: &apos;Mathias Stearn&apos;, &apos;email&apos;: &apos;mathias@10gen.com&apos;}
&lt;p&gt;Message: Plug memory leak &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-1827&quot; title=&quot;Memory leak when there&amp;#39;s multiple query plans with empty result&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-1827&quot;&gt;&lt;del&gt;SERVER-1827&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo/commit/4f5c02f8d92ff213b71b88f5eb643b7f62b50abc&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo/commit/4f5c02f8d92ff213b71b88f5eb643b7f62b50abc&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="19287" author="dwight_10gen" created="Mon, 18 Oct 2010 13:01:16 +0000"  >&lt;p&gt;i assume so given fix version isn&apos;t marked as 1.6.3 above...&lt;/p&gt;</comment>
                            <comment id="18992" author="fabioferrari" created="Fri, 8 Oct 2010 14:02:24 +0000"  >&lt;p&gt;Using valgrind I can see leaks of 32k in queries using the 1.6.3. Same problem?&lt;/p&gt;</comment>
                            <comment id="18454" author="redbeard0531" created="Wed, 22 Sep 2010 23:27:01 +0000"  >&lt;p&gt;Thanks for the patch&lt;/p&gt;</comment>
                            <comment id="18453" author="auto" created="Wed, 22 Sep 2010 23:25:35 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;login&apos;: &apos;RedBeard0531&apos;, &apos;name&apos;: &apos;Mathias Stearn&apos;, &apos;email&apos;: &apos;mathias@10gen.com&apos;}
&lt;p&gt;Message: Plug memory leak &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-1827&quot; title=&quot;Memory leak when there&amp;#39;s multiple query plans with empty result&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-1827&quot;&gt;&lt;del&gt;SERVER-1827&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo/commit/65b31a0ba67a479340e3f5e3ca243dcc932b2b0d&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo/commit/65b31a0ba67a479340e3f5e3ca243dcc932b2b0d&lt;/a&gt;&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                            <attachment id="10464" name="patch.diff" size="725" author="cverutin" created="Wed, 22 Sep 2010 13:00:09 +0000"/>
                            <attachment id="10463" name="val.log" size="743567" author="cverutin" created="Wed, 22 Sep 2010 13:00:09 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>5.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Wed, 22 Sep 2010 23:25:35 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        13 years, 17 weeks, 1 day ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>ramon.fernandez@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            13 years, 17 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>auto</customfieldvalue>
            <customfieldvalue>cverutin</customfieldvalue>
            <customfieldvalue>dwight@mongodb.com</customfieldvalue>
            <customfieldvalue>fabioferrari</customfieldvalue>
            <customfieldvalue>mathias@mongodb.com</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrpeo7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrg3i7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>7470</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|ht0hiv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                    </customfields>
    </item>
</channel>
</rss>