<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 22:01:50 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>[CXX-1224] mongocxx::client constructor fails on Windows 7</title>
                <link>https://jira.mongodb.org/browse/CXX-1224</link>
                <project id="11980" key="CXX">C++ Driver</project>
                    <description>&lt;p&gt;Basically, if I try to use the simple mongo client data structure listed in the  tutorial, I get a hard crash in Windows 7.&lt;/p&gt;

&lt;p&gt;This is my fully-contained working example that demonstrates the issue:&lt;br/&gt;
```&lt;br/&gt;
#include &amp;lt;cstdint&amp;gt;&lt;br/&gt;
#include &amp;lt;iostream&amp;gt;&lt;br/&gt;
#include &amp;lt;vector&amp;gt;&lt;/p&gt;

&lt;p&gt;#include &amp;lt;bsoncxx/json.hpp&amp;gt;&lt;br/&gt;
#include &amp;lt;mongocxx/client.hpp&amp;gt;&lt;br/&gt;
#include &amp;lt;mongocxx/stdx.hpp&amp;gt;&lt;br/&gt;
#include &amp;lt;mongocxx/uri.hpp&amp;gt;&lt;/p&gt;

&lt;p&gt;using bsoncxx::builder::stream::close_array;&lt;br/&gt;
using bsoncxx::builder::stream::close_document;&lt;br/&gt;
using bsoncxx::builder::stream::document;&lt;br/&gt;
using bsoncxx::builder::stream::finalize;&lt;br/&gt;
using bsoncxx::builder::stream::open_array;&lt;br/&gt;
using bsoncxx::builder::stream::open_document;&lt;/p&gt;

&lt;p&gt;int main(void)&lt;br/&gt;
{&lt;br/&gt;
  try {&lt;/p&gt;

&lt;p&gt;    mongocxx::uri uri(&quot;mongodb://localhost:27017&quot;);&lt;br/&gt;
    // this is what&apos;s failing&lt;br/&gt;
    mongocxx::client client&lt;/p&gt;
{ uri }
&lt;p&gt;;&lt;br/&gt;
  }&lt;br/&gt;
  catch (std::exception err) &lt;/p&gt;
{
    std::cout &amp;lt;&amp;lt; err.what() &amp;lt;&amp;lt; &quot;\n&quot;;
  }

&lt;p&gt;  return 0;&lt;br/&gt;
}&lt;br/&gt;
```&lt;/p&gt;

&lt;p&gt;It seems like it&apos;s an issue deep in the Mongo callstack:&lt;br/&gt;
&amp;gt;	libmongoc-1.0.dll!_InterlockedExchangeAdd64(volatile __int64 * Addend, __int64 Value) Line 5603	C&lt;/p&gt;

&lt;p&gt;Namely, this line here:&lt;br/&gt;
```&lt;br/&gt;
    do &lt;/p&gt;
{
        // this one is what VS picks up on
        Old = *Addend;
    }
&lt;p&gt; while (InterlockedCompareExchange64(Addend,&lt;br/&gt;
                                          Old + Value,&lt;br/&gt;
                                          Old) != Old);&lt;br/&gt;
```&lt;/p&gt;


&lt;p&gt;I installed the mongo-cxx-driver using vcpkg as well.&lt;/p&gt;</description>
                <environment>Windows 7, 32 bit binary, 64 bit OS</environment>
        <key id="355195">CXX-1224</key>
            <summary>mongocxx::client constructor fails on Windows 7</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="13202">Works as Designed</resolution>
                                        <assignee username="david.golden@mongodb.com">David Golden</assignee>
                                    <reporter username="exbigboss">Christian Mazakas</reporter>
                        <labels>
                    </labels>
                <created>Fri, 17 Feb 2017 18:33:29 +0000</created>
                <updated>Fri, 27 Oct 2023 13:13:46 +0000</updated>
                            <resolved>Tue, 21 Feb 2017 18:53:28 +0000</resolved>
                                    <version>3.0.3</version>
                                                    <component>Portability</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1505304" author="david.golden" created="Tue, 21 Feb 2017 18:53:28 +0000"  >&lt;p&gt;I&apos;m glad you figured it out.  As you can see from related tickets, we know this is something we could make more user-friendly.&lt;/p&gt;</comment>
                            <comment id="1505243" author="exbigboss" created="Tue, 21 Feb 2017 18:17:33 +0000"  >&lt;p&gt;Okay, turns out that I&apos;m a super duper dummy.&lt;/p&gt;

&lt;p&gt;All I had to do was revert the expression `mongocxx::instance{}` into `mongocxx::instance instance{}` and the code works beautifully.&lt;/p&gt;

&lt;p&gt;Basically, the instance stuff isn&apos;t mentioned  that much in the tutorials nor is it mentioned what the lifetime of it needs to be.&lt;/p&gt;

&lt;p&gt;Ideally the code should throw a useful exception instead of having a segmentation fault which is what it was basically doing for me. &lt;/p&gt;

&lt;p&gt;But the MongoDB C++ driver is amazing and I appreciate all the hard work that goes into it. &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>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="347240">CXX-1196</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="347247">CXX-1197</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <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|hsv6cf:</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>