<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:13:35 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-1909] Improve mongoc_init and mongoc_cleanup docs</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-1909</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;&lt;b&gt;Update&lt;/b&gt;: to close this ticket, ensure that it&apos;s documented that mongoc_cleanup should be called once, and no other C Driver functions, not even mongoc_init, can be called after. Also, add links between mongoc_init, mongoc_cleanup, and the index page. Right now &lt;a href=&quot;http://mongoc.org/libmongoc/current/mongoc_cleanup.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;mongoc_cleanup&lt;/a&gt; is isolated.&lt;/p&gt;

&lt;p&gt;After a long debugging tour I learned&lt;br/&gt;
that calling mongoc_init() and mongoc_cleanup() multiple times is bad practice&lt;br/&gt;
which might result in segmentation faults.&lt;/p&gt;

&lt;p&gt;I suggest hereby adding&lt;/p&gt;

&lt;p&gt;assert(once==MONGOC_ONCE_INIT)&lt;/p&gt;

&lt;p&gt;to the implemetnations of these two functions,&lt;br/&gt;
for indicating that there might be a problem. &lt;/p&gt;

&lt;p&gt;Regards&lt;br/&gt;
Andre&lt;/p&gt;</description>
                <environment></environment>
        <key id="330410">CDRIVER-1909</key>
            <summary>Improve mongoc_init and mongoc_cleanup docs</summary>
                <type id="4" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14710&amp;avatarType=issuetype">Improvement</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="jesse@mongodb.com">A. Jesse Jiryu Davis</assignee>
                                    <reporter username="andre.maute">andre maute</reporter>
                        <labels>
                    </labels>
                <created>Tue, 8 Nov 2016 14:29:18 +0000</created>
                <updated>Sat, 28 Jan 2017 13:05:50 +0000</updated>
                            <resolved>Fri, 27 Jan 2017 03:19:23 +0000</resolved>
                                    <version>1.3.3</version>
                                    <fixVersion>1.6.0</fixVersion>
                                    <component>docs</component>
                    <component>libmongoc</component>
                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="1487487" author="xgen-internal-githook" created="Sat, 28 Jan 2017 13:05:50 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;ajdavis&apos;, u&apos;name&apos;: u&apos;A. Jesse Jiryu Davis&apos;, u&apos;email&apos;: u&apos;jesse@mongodb.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/CDRIVER-1909&quot; title=&quot;Improve mongoc_init and mongoc_cleanup docs&quot; class=&quot;issue-link&quot; data-issue-key=&quot;CDRIVER-1909&quot;&gt;&lt;del&gt;CDRIVER-1909&lt;/del&gt;&lt;/a&gt; improve init / cleanup docs&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-c-driver/commit/5bda9c810ae42647a493bfb23388686cd3439cee&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-c-driver/commit/5bda9c810ae42647a493bfb23388686cd3439cee&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1436390" author="andre.maute" created="Thu, 17 Nov 2016 12:22:10 +0000"  >&lt;p&gt;Hi Jesse,&lt;/p&gt;

&lt;p&gt;yes I can confirm that.&lt;/p&gt;

&lt;p&gt;The debugging process was quite frustrating,&lt;br/&gt;
because we had only one installation where our problem happend.&lt;br/&gt;
At the beginning of the debugging session there was no hint at all&lt;br/&gt;
that pointed us to our usage of the mongoc api.&lt;/p&gt;

&lt;p&gt;Regards&lt;br/&gt;
Andre&lt;/p&gt;



</comment>
                            <comment id="1430560" author="jesse" created="Wed, 9 Nov 2016 21:05:04 +0000"  >&lt;p&gt;Thanks Andre. Calling &lt;b&gt;any&lt;/b&gt; C Driver function after calling mongoc_cleanup is expected to fail. Can you confirm that, if you don&apos;t call any C Driver functions after calling mongoc_cleanup, &lt;b&gt;then&lt;/b&gt; everything works as expected?&lt;/p&gt;</comment>
                            <comment id="1430303" author="bjori" created="Wed, 9 Nov 2016 17:00:09 +0000"  >&lt;p&gt;Ahh, intersting. So &lt;tt&gt;mongoc_init()&lt;/tt&gt; after a &lt;tt&gt;mongoc_cleanup()&lt;/tt&gt;. Yes, I can see that being a problem.&lt;br/&gt;
I don&apos;t think we should assert on multiple mongoc_init(), that is &quot;valid&quot;. But an init after cleanup is undefined behaviour...&lt;/p&gt;</comment>
                            <comment id="1430117" author="andre.maute" created="Wed, 9 Nov 2016 13:54:01 +0000"  >&lt;p&gt;Dear Hannes,&lt;/p&gt;

&lt;p&gt;so here is our relevant stack trace,&lt;br/&gt;
as you can see there is NO indicator pointing to a mongoc function.&lt;/p&gt;

&lt;p&gt;Essentially our code was&lt;br/&gt;
1. mongoc_init&lt;br/&gt;
2. mongoc_init&lt;br/&gt;
3. mongoc_cleanup&lt;br/&gt;
4. still use mongoc&lt;br/&gt;
5. mongoc_cleanup&lt;/p&gt;

&lt;p&gt;After fixing, i.e.  removing 2. and 3., the segfaults went away.&lt;br/&gt;
If we had had the requested assert within mongoc_init&lt;br/&gt;
we would have been alerted much earlier for inspecting the relevant code.&lt;/p&gt;

&lt;p&gt;Additionally, we expect another problem (after inspecting the code)&lt;br/&gt;
with the sequence&lt;br/&gt;
1. mongoc_init&lt;br/&gt;
2. mongoc_cleanup&lt;br/&gt;
3. mongoc_init&lt;/p&gt;

&lt;p&gt;Regards Andre&lt;/p&gt;

&lt;p&gt;---- begin &apos;uname -a&apos; ----&lt;br/&gt;
Linux user-VirtualBox 4.4.0-42-generic #62~14.04.1-Ubuntu SMP Fri Oct 7 23:15:48 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux&lt;br/&gt;
---- end &apos;uname -a&apos; ----&lt;/p&gt;

&lt;p&gt;---- begin &apos;gcc -v&apos; ----&lt;br/&gt;
Using built-in specs.&lt;br/&gt;
COLLECT_GCC=gcc&lt;br/&gt;
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper&lt;br/&gt;
Target: x86_64-linux-gnu&lt;br/&gt;
Configured with: ../src/configure -v --with-pkgversion=&apos;Ubuntu 4.8.4-2ubuntu1~14.04.3&apos; --with-bugurl=&lt;a href=&quot;file:///usr/share/doc/gcc-4.8/README.Bugs&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;file:///usr/share/doc/gcc-4.8/README.Bugs&lt;/a&gt; --enable-languages=c,c+&lt;ins&gt;,java,go,d,fortran,objc,obj-c&lt;/ins&gt;+ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu&lt;br/&gt;
Thread model: posix&lt;br/&gt;
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3) &lt;br/&gt;
---- end &apos;gcc -v&apos; ----&lt;/p&gt;

&lt;p&gt;---- begin stack trace ----&lt;br/&gt;
Program received signal SIGABRT, Aborted.&lt;br/&gt;
0x00007ffff4b13c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56&lt;br/&gt;
56	../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.&lt;br/&gt;
(gdb) bt&lt;br/&gt;
#0  0x00007ffff4b13c37 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56&lt;br/&gt;
#1  0x00007ffff4b17028 in __GI_abort () at abort.c:89&lt;br/&gt;
#2  0x00007ffff4b502a4 in __libc_message (do_abort=do_abort@entry=1, fmt=fmt@entry=0x7ffff4c5e6b0 &quot;*** Error in `%s&apos;: %s: 0x%s ***\n&quot;) at ../sysdeps/posix/libc_fatal.c:175&lt;br/&gt;
#3  0x00007ffff4b5aff7 in malloc_printerr (action=&amp;lt;optimized out&amp;gt;, str=0x7ffff4c5ea30 &quot;munmap_chunk(): invalid pointer&quot;, ptr=&amp;lt;optimized out&amp;gt;) at malloc.c:4996&lt;br/&gt;
#4  0x00007ffff5479529 in std::string::assign(std::string const&amp;amp;) () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6&lt;br/&gt;
#5  0x0000000000f4eacd in Catch::SourceLineInfo::operator= (this=0x7fffffffda70) at /home/user/project/test/server/../catch.hpp:348&lt;br/&gt;
#6  0x0000000000f4eb58 in Catch::AssertionInfo::operator= (this=0x7fffffffda68) at /home/user/project/test/server/../catch.hpp:789&lt;br/&gt;
#7  0x0000000000f4ec69 in Catch::AssertionResult::operator= (this=0x7fffffffda68) at /home/user/project/test/server/../catch.hpp:812&lt;br/&gt;
#8  0x0000000000f4f072 in Catch::RunContext::assertionEnded (this=0x7fffffffda30, result=...) at /home/user/project/test/server/../catch.hpp:5727&lt;br/&gt;
#9  0x0000000000f2ed96 in Catch::ResultBuilder::handleResult (this=0x7fffffffcb20, result=...) at /home/user/project/test/server/../catch.hpp:7994&lt;br/&gt;
#10 0x0000000000f2ecb5 in Catch::ResultBuilder::captureExpression (this=0x7fffffffcb20) at /home/user/project/test/server/../catch.hpp:7990&lt;br/&gt;
#11 0x0000000000f2e607 in Catch::ResultBuilder::endExpression (this=0x7fffffffcb20) at /home/user/project/test/server/../catch.hpp:7952&lt;br/&gt;
#12 0x0000000000fca76c in Catch::ExpressionLhs&amp;lt;bool&amp;gt;::endExpression (this=0x7fffffffcb10) at /home/user/project/test/server/../catch.hpp:1809&lt;br/&gt;
#13 0x00000000013dfacb in resetDatabase () at /home/user/project/test/server/persistence/databasehelper.cpp:22&lt;br/&gt;
#14 0x00000000013d7b6e in ____C_A_T_C_H____T_E_S_T____9 () at /home/user/project/test/server/persistence/tst_gatewaydeletedjob.cpp:21&lt;br/&gt;
#15 0x0000000000f53bac in Catch::FreeFunctionTestCase::invoke (this=0x3e505d0) at /home/user/project/test/server/../catch.hpp:6297&lt;br/&gt;
#16 0x0000000000f28ba1 in Catch::TestCase::invoke (this=0x3e78eb0) at /home/user/project/test/server/../catch.hpp:7218&lt;br/&gt;
#17 0x0000000000f5184d in Catch::RunContext::invokeActiveTestCase (this=0x7fffffffda30) at /home/user/project/test/server/../catch.hpp:5891&lt;br/&gt;
#18 0x0000000000f5109a in Catch::RunContext::runCurrentTest (this=0x7fffffffda30, redirectedCout=&quot;&quot;, redirectedCerr=&quot;&quot;) at /home/user/project/test/server/../catch.hpp:5862&lt;br/&gt;
#19 0x0000000000f4e3ff in Catch::RunContext::runTest (this=0x7fffffffda30, testCase=...) at /home/user/project/test/server/../catch.hpp:5687&lt;br/&gt;
#20 0x0000000000f22fec in Catch::runTests (config=...) at /home/user/project/test/server/../catch.hpp:6030&lt;br/&gt;
#21 0x0000000000f52b6b in Catch::Session::run (this=0x7fffffffdc70) at /home/user/project/test/server/../catch.hpp:6138&lt;br/&gt;
#22 0x0000000000f52924 in Catch::Session::run (this=0x7fffffffdc70, argc=3, argv=0x7fffffffde68) at /home/user/project/test/server/../catch.hpp:6117&lt;br/&gt;
#23 0x0000000000f355a2 in main (argc=3, argv=0x7fffffffde68) at /home/user/project/test/server/../catch.hpp:10027&lt;br/&gt;
---- end stack trace ----&lt;/p&gt;



&lt;p&gt;Am Dienstag, November 08, 2016 18:08 CET, &quot;Hannes Magnusson (JIRA)&quot; &amp;lt;jira@mongodb.org&amp;gt; schrieb: &lt;/p&gt;




&lt;p&gt;&amp;#8211; &lt;br/&gt;
sodge IT GmbH&lt;br/&gt;
Adlerstra&#223;e 5&lt;br/&gt;
72336 Balingen&lt;/p&gt;

&lt;p&gt;Mail: andre.maute@sodgeit.de&lt;/p&gt;

&lt;p&gt;URL: &lt;a href=&quot;http://www.sodgeit.de&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.sodgeit.de&lt;/a&gt;&lt;br/&gt;
Telefon: +49-7433-95 59 28 4&lt;br/&gt;
Telefon: +49-7433-27 52 36&lt;br/&gt;
Fax:     +49-7433-51 32&lt;br/&gt;
&amp;#8212;&lt;br/&gt;
Sitz der Gesellschaft: Balingen&lt;br/&gt;
Registergericht: Amtsgericht Stuttgart HRB 740109&lt;br/&gt;
Gesch&#228;ftsf&#252;hrer: Matthias Ehinger / David Feurle / G&#246;tz Martinek&lt;/p&gt;

</comment>
                            <comment id="1429387" author="bjori" created="Tue, 8 Nov 2016 17:07:50 +0000"  >&lt;p&gt;I think that would be helpful as I cannot see how this could happen, and I believe there are other underlaying factors that caused the segfault your are referring to.&lt;/p&gt;</comment>
                            <comment id="1429343" author="andre.maute" created="Tue, 8 Nov 2016 16:38:01 +0000"  >&lt;p&gt;at the moment not,&lt;br/&gt;
if in need, I might revert my fixes for our project and obfuscate our &lt;br/&gt;
customer&apos;s functionality.&lt;/p&gt;

&lt;p&gt;Regards&lt;br/&gt;
Andre&lt;/p&gt;



&lt;p&gt;&amp;#8211; &lt;br/&gt;
sodge IT GmbH&lt;br/&gt;
Hauptwasen 8&lt;br/&gt;
72336 Balingen&lt;/p&gt;

&lt;p&gt;Mail: andre.maute@sodgeit.de&lt;/p&gt;

&lt;p&gt;URL: &lt;a href=&quot;http://www.sodgeit.de&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://www.sodgeit.de&lt;/a&gt;&lt;br/&gt;
Mobil:   +49-176-86 77 81 47&lt;br/&gt;
Telefon: +49-7433-95 59 28 4&lt;br/&gt;
Fax:     +49-7433-95 59 28 5&lt;br/&gt;
&amp;#8212;&lt;br/&gt;
Registergericht: Amtsgericht Stuttgart HRB 740109&lt;br/&gt;
Gesch&#228;ftsf&#252;hrer: Matthias Ehinger / David Feurle / G&#246;tz Martinek&lt;/p&gt;


</comment>
                            <comment id="1429330" author="bjori" created="Tue, 8 Nov 2016 16:30:28 +0000"  >&lt;p&gt;Do you have the stacktrace from the segfault?&lt;br/&gt;
I&apos;m curious what exactly happened and what it caused&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|hrb91b:</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>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="1481">C Driver 2017 1 - Jan 20, 2017</customfieldvalue>
    <customfieldvalue id="1558">C Driver 2017 2 - Feb 10, 2018</customfieldvalue>

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