<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:19:21 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>[CDRIVER-3904] &quot;Falling back to malloc for counters&quot; not managed by the logging handler</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-3904</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;I&apos;m using the C driver in a program. I have set my own logging handler function (as described in &lt;a href=&quot;http://mongoc.org/libmongoc/current/logging.html)&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://mongoc.org/libmongoc/current/logging.html)&lt;/a&gt; to avoid printing anything in standard output (my function writes to a log file instead that standard output).&lt;/p&gt;

&lt;p&gt;However, I&apos;m still getting this kind of warning in my programs output:&lt;/p&gt;

&lt;p&gt;&lt;tt&gt;2021/02/04 22:33:32.0740: [ 6745]: WARNING: mongoc: Falling back to malloc for counters.&lt;/tt&gt;&lt;/p&gt;

&lt;p&gt;Should I understand that kind of &quot;Failling back to malloc for counters&quot; warning are not managed by the logging handler and always go to standard output? Or should they and I&apos;m doing something wrong in my program?&lt;/p&gt;

&lt;p&gt;(I have seen issue &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-1504&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;https://jira.mongodb.org/browse/CDRIVER-1504&lt;/a&gt;, which provides a solution to disable &quot;Failling back to malloc for counters&quot; warning. However, note that in my case I want these warning... but managed properly by my logging handler instead that printed in standard output)&lt;/p&gt;</description>
                <environment></environment>
        <key id="1616317">CDRIVER-3904</key>
            <summary>&quot;Falling back to malloc for counters&quot; not managed by the logging handler</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="13201">Fixed</resolution>
                                        <assignee username="clyde.bazile@mongodb.com">Clyde Bazile III</assignee>
                                    <reporter username="fermin.galanmarquez@telefonica.com">Ferm&#237;n Gal&#225;n</reporter>
                        <labels>
                    </labels>
                <created>Mon, 8 Feb 2021 17:15:57 +0000</created>
                <updated>Sat, 28 Oct 2023 11:28:33 +0000</updated>
                            <resolved>Thu, 11 Feb 2021 18:16:48 +0000</resolved>
                                    <version>1.16.0</version>
                                    <fixVersion>1.17.5</fixVersion>
                                    <component>Logging</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="3708658" author="xgen-internal-githook" created="Thu, 8 Apr 2021 18:43:55 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Ferm&#237;n Gal&#225;n M&#225;rquez&apos;, &apos;email&apos;: &apos;fgalan@users.noreply.github.com&apos;, &apos;username&apos;: &apos;fgalan&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-3904&quot; title=&quot;&amp;quot;Falling back to malloc for counters&amp;quot; not managed by the logging handler&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-3904&quot;&gt;&lt;del&gt;CDRIVER-3904&lt;/del&gt;&lt;/a&gt; improve documentation regarding when to call mongoc_log_set_handler (#739)&lt;br/&gt;
Branch: r1.17&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/fbc6babbd7032d30c420729ff613136e39412eb2&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/fbc6babbd7032d30c420729ff613136e39412eb2&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3708657" author="xgen-internal-githook" created="Thu, 8 Apr 2021 18:43:53 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Clyde Bazile&apos;, &apos;email&apos;: &apos;34226620+bazile-clyde@users.noreply.github.com&apos;, &apos;username&apos;: &apos;bazile-clyde&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-3904&quot; title=&quot;&amp;quot;Falling back to malloc for counters&amp;quot; not managed by the logging handler&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-3904&quot;&gt;&lt;del&gt;CDRIVER-3904&lt;/del&gt;&lt;/a&gt; move log handler above init in logging example (#736)&lt;br/&gt;
Branch: r1.17&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/99a343ef8427b4fc86b97106fe146cf28c02b4e3&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/99a343ef8427b4fc86b97106fe146cf28c02b4e3&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3679460" author="xgen-internal-githook" created="Tue, 23 Mar 2021 15:40:31 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Ferm&#237;n Gal&#225;n M&#225;rquez&apos;, &apos;email&apos;: &apos;fgalan@users.noreply.github.com&apos;, &apos;username&apos;: &apos;fgalan&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-3904&quot; title=&quot;&amp;quot;Falling back to malloc for counters&amp;quot; not managed by the logging handler&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-3904&quot;&gt;&lt;del&gt;CDRIVER-3904&lt;/del&gt;&lt;/a&gt; improve documentation regarding when to call mongoc_log_set_handler (#739)&lt;br/&gt;
Branch: csot&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/43f5997ee39d3971001f0c8f1e8a99ab072b2869&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/43f5997ee39d3971001f0c8f1e8a99ab072b2869&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3679457" author="xgen-internal-githook" created="Tue, 23 Mar 2021 15:40:25 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Clyde Bazile&apos;, &apos;email&apos;: &apos;34226620+bazile-clyde@users.noreply.github.com&apos;, &apos;username&apos;: &apos;bazile-clyde&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-3904&quot; title=&quot;&amp;quot;Falling back to malloc for counters&amp;quot; not managed by the logging handler&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-3904&quot;&gt;&lt;del&gt;CDRIVER-3904&lt;/del&gt;&lt;/a&gt; move log handler above init in logging example (#736)&lt;br/&gt;
Branch: csot&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/903b55c22c3dc31c60862f77ab5a3914bd1db0ff&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/903b55c22c3dc31c60862f77ab5a3914bd1db0ff&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3627637" author="xgen-internal-githook" created="Mon, 22 Feb 2021 15:23:33 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Ferm&#237;n Gal&#225;n M&#225;rquez&apos;, &apos;email&apos;: &apos;fgalan@users.noreply.github.com&apos;, &apos;username&apos;: &apos;fgalan&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-3904&quot; title=&quot;&amp;quot;Falling back to malloc for counters&amp;quot; not managed by the logging handler&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-3904&quot;&gt;&lt;del&gt;CDRIVER-3904&lt;/del&gt;&lt;/a&gt; improve documentation regarding when to call mongoc_log_set_handler (#739)&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/43f5997ee39d3971001f0c8f1e8a99ab072b2869&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/43f5997ee39d3971001f0c8f1e8a99ab072b2869&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3612820" author="JIRAUSER1269441" created="Thu, 11 Feb 2021 22:36:19 +0000"  >&lt;p&gt;Tested. Problem fixed&#160;&lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;</comment>
                            <comment id="3612313" author="JIRAUSER1269441" created="Thu, 11 Feb 2021 19:20:18 +0000"  >&lt;p&gt;Clyde Bazile III: I will test as soon as I can and report the result in this issue.&lt;/p&gt;

&lt;p&gt;In addition, I have provided some feedback in &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/pull/736&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/pull/736&lt;/a&gt; in the hope you find it useful.&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;</comment>
                            <comment id="3612192" author="xgen-internal-githook" created="Thu, 11 Feb 2021 18:14:07 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Clyde Bazile&apos;, &apos;email&apos;: &apos;34226620+bazile-clyde@users.noreply.github.com&apos;, &apos;username&apos;: &apos;bazile-clyde&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-3904&quot; title=&quot;&amp;quot;Falling back to malloc for counters&amp;quot; not managed by the logging handler&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-3904&quot;&gt;&lt;del&gt;CDRIVER-3904&lt;/del&gt;&lt;/a&gt; move log handler above init in logging example (#736)&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/903b55c22c3dc31c60862f77ab5a3914bd1db0ff&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/903b55c22c3dc31c60862f77ab5a3914bd1db0ff&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="3612053" author="clyde.bazile" created="Thu, 11 Feb 2021 17:21:15 +0000"  >&lt;p&gt;&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/pull/736&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/pull/736&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;The log handler can be set before the call to &lt;tt&gt;mongoc_init&lt;/tt&gt;. &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=fermin.galanmarquez%40telefonica.com&quot; class=&quot;user-hover&quot; rel=&quot;fermin.galanmarquez@telefonica.com&quot;&gt;fermin.galanmarquez@telefonica.com&lt;/a&gt;&#160;that &lt;em&gt;should&lt;/em&gt; fix the issue, but please let us know if it doesn&apos;t. &lt;/p&gt;

&lt;p&gt;The linked PR clarifies &lt;tt&gt;mongoc_log_set_handler&lt;/tt&gt;&#160;can be called &lt;em&gt;before&lt;/em&gt;&#160; &lt;tt&gt;mongoc_init.&lt;/tt&gt;&lt;/p&gt;</comment>
                            <comment id="3606517" author="jmikola@gmail.com" created="Tue, 9 Feb 2021 13:57:34 +0000"  >&lt;p&gt;AFAIK, the the destination stream is not relevant. &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/1.17.4/src/libmongoc/src/mongoc/mongoc-log.c#L131&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;mongoc_log_default_handler&lt;/a&gt; &lt;em&gt;does&lt;/em&gt; decide to use stderr or stdout based on the log level; however, once you assign a custom log handler &lt;tt&gt;gLogFunc&lt;/tt&gt; is re-assigned and the default handler is never used again (unless intentionally restored).&lt;/p&gt;

&lt;p&gt;The behavior you&apos;re seeing likely originates from &lt;tt&gt;mongoc_init&lt;/tt&gt; calling &lt;tt&gt;&amp;#95;mongoc_counters_init&lt;/tt&gt;. I&apos;m not sure if it&apos;s possible to assign log handlers &lt;em&gt;before&lt;/em&gt; calling &lt;tt&gt;mongoc_init&lt;/tt&gt;, but that seems like that may be only way to address without internal changes to libmongoc (e.g. delaying counter initialization until users have a chance to set a custom logger). &lt;a href=&quot;http://mongoc.org/libmongoc/current/logging.html#custom-log-handlers&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Custom Log Handlers&lt;/a&gt; also demonstrates calling &lt;tt&gt;mongoc_init&lt;/tt&gt; before &lt;tt&gt;mongoc_log_set_handler&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;Looking at the source of &lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/blob/1.17.4/src/libmongoc/src/mongoc/mongoc-log.c#L51&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;mongoc_log_set_handler&lt;/a&gt;, it appears to only initialize a mutex and assign two globals (within a mutex lock). I don&apos;t believe that depends on anything setup by &lt;tt&gt;mongoc_init&lt;/tt&gt; so you may be able to just move &lt;tt&gt;mongoc_log_set_handler&lt;/tt&gt; &lt;em&gt;before&lt;/em&gt; &lt;tt&gt;mongoc_init&lt;/tt&gt; to resolve this.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=kevin.albertson&quot; class=&quot;user-hover&quot; rel=&quot;kevin.albertson&quot;&gt;kevin.albertson&lt;/a&gt;, &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=clyde.bazile&quot; class=&quot;user-hover&quot; rel=&quot;clyde.bazile&quot;&gt;clyde.bazile&lt;/a&gt;: If that&apos;s suitable, then perhaps you can repurpose this ticket to revise the doc example in &lt;a href=&quot;http://mongoc.org/libmongoc/current/logging.html#custom-log-handlers&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;Custom Log Handlers&lt;/a&gt;.&lt;/p&gt;


</comment>
                            <comment id="3606436" author="JIRAUSER1269441" created="Tue, 9 Feb 2021 12:52:02 +0000"  >&lt;p&gt;Maybe what is happening is the &quot;Failling back to malloc for counters&quot; trace is sent to stderr instead of stdout but the log handler only deals with traces aimed at stdout?&lt;/p&gt;

&lt;p&gt;(Not sure, just trying to give ideas in the hope they can be useful &lt;img class=&quot;emoticon&quot; src=&quot;https://jira.mongodb.org/images/icons/emoticons/smile.png&quot; height=&quot;16&quot; width=&quot;16&quot; align=&quot;absmiddle&quot; alt=&quot;&quot; border=&quot;0&quot;/&gt;)&lt;/p&gt;</comment>
                            <comment id="3605417" author="esha.bhargava" created="Mon, 8 Feb 2021 20:39:46 +0000"  >&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=fermin.galanmarquez%40telefonica.com&quot; class=&quot;user-hover&quot; rel=&quot;fermin.galanmarquez@telefonica.com&quot;&gt;fermin.galanmarquez@telefonica.com&lt;/a&gt; Thank  you for reporting this issue! We&apos;ll look into it soon and get back to you.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hyfgrb:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9223372036854775807</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>