<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Wed Feb 07 21:08: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-145] bson_oid_gen() is not thread-safe</title>
                <link>https://jira.mongodb.org/browse/CDRIVER-145</link>
                <project id="10030" key="CDRIVER">C Driver</project>
                    <description>&lt;p&gt;bson_oid_gen() is not thread-safe.&lt;br/&gt;
It uses static &apos;incr&apos; integer variable to increment. When enough threads accessing the method, the returned oid will be the same as returned just previously.&lt;/p&gt;</description>
                <environment>*</environment>
        <key id="39791">CDRIVER-145</key>
            <summary>bson_oid_gen() is not thread-safe</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="gjmurakami">Gary Murakami</assignee>
                                    <reporter username="pawel">Pawel</reporter>
                        <labels>
                            <label>bson</label>
                    </labels>
                <created>Tue, 29 May 2012 08:29:16 +0000</created>
                <updated>Wed, 3 May 2017 22:14:12 +0000</updated>
                            <resolved>Sat, 9 Nov 2013 01:08:59 +0000</resolved>
                                    <version>0.5.2</version>
                    <version>0.6</version>
                                    <fixVersion>TBD</fixVersion>
                                                        <votes>0</votes>
                                    <watches>3</watches>
                                                                                                                <comments>
                            <comment id="453952" author="christian.hergert@10gen.com" created="Sat, 9 Nov 2013 01:08:51 +0000"  >&lt;p&gt;This is fixed in libbson. You can use the default bson_context_t which uses a thread-safe atomic, or keep your own copy for other potential optimizations.&lt;/p&gt;</comment>
                            <comment id="293054" author="fatherbrain" created="Tue, 19 Mar 2013 15:48:09 +0000"  >&lt;p&gt;One more change should be made before closing out this issue: in bson_oid_gen(), we have the declaration&lt;/p&gt;
&lt;p/&gt;
&lt;div id=&quot;syntaxplugin&quot; class=&quot;syntaxplugin&quot; style=&quot;border: 1px dashed #bbb; border-radius: 5px !important; overflow: auto; max-height: 30em;&quot;&gt;
&lt;table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; border=&quot;0&quot; width=&quot;100%&quot; style=&quot;font-size: 1em; line-height: 1.4em !important; font-weight: normal; font-style: normal; color: black;&quot;&gt;
		&lt;tbody &gt;
				&lt;tr id=&quot;syntaxplugin_code_and_gutter&quot;&gt;
						&lt;td  style=&quot; line-height: 1.4em !important; padding: 0em; vertical-align: top;&quot;&gt;
					&lt;pre style=&quot;font-size: 1em; margin: 0 10px;  margin-top: 10px;   margin-bottom: 10px;  width: auto; padding: 0;&quot;&gt;&lt;span style=&quot;color: black; font-family: &apos;Consolas&apos;, &apos;Bitstream Vera Sans Mono&apos;, &apos;Courier New&apos;, Courier, monospace !important;&quot;&gt;static int fuzz = 0;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;
&lt;p&gt;Even if we register a thread-safe fuzz function, multiple threads can end up using the same fuzz, because the fuzz value is stored in the static fuzz variable, shared by all the threads.&lt;/p&gt;

&lt;p&gt;This problem has a simple fix: &lt;b&gt;don&apos;t&lt;/b&gt; declare fuzz as static.&lt;/p&gt;</comment>
                            <comment id="148415" author="gjmurakami" created="Sat, 28 Jul 2012 06:16:45 +0000"  >&lt;p&gt;Re: bson_oid_gen()&lt;br/&gt;
/**&lt;/p&gt;
&lt;ul&gt;
	&lt;li&gt;Set a function to be used to generate the incrementing part&lt;/li&gt;
	&lt;li&gt;of an object id (last four bytes). If you need thread-safety&lt;/li&gt;
	&lt;li&gt;in generating object ids, you should set this function.&lt;br/&gt;
 *&lt;/li&gt;
	&lt;li&gt;@param func a pointer to a function that returns an int.&lt;br/&gt;
 */&lt;br/&gt;
MONGO_EXPORT void bson_set_oid_inc( int ( *func )( void ) );&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="148410" author="gjmurakami" created="Sat, 28 Jul 2012 05:42:38 +0000"  >&lt;p&gt;Another concern:&lt;br/&gt;
mongo.c:52:static char _hp&lt;span class=&quot;error&quot;&gt;&amp;#91;sizeof(hp-&amp;gt;host)+12&amp;#93;&lt;/span&gt;;&lt;br/&gt;
just make it a non-static automatic stack-allocated&lt;/p&gt;
</comment>
                            <comment id="129459" author="pawel" created="Sat, 9 Jun 2012 20:24:04 +0000"  >&lt;p&gt;Apparently, this is already solved by having allowing external functions to generated both the incremented part of the OID and its fuzz. This issue can be closed.&lt;/p&gt;</comment>
                            <comment id="123763" author="pawel" created="Tue, 29 May 2012 08:41:47 +0000"  >&lt;p&gt;May be GCC atomics can be considered, at least as a #if&lt;br/&gt;
&lt;a href=&quot;http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html&lt;/a&gt;&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|hrmmgv:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>45718</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                    <customfield id="customfield_10557" key="com.pyxis.greenhopper.jira:gh-sprint">
                        <customfieldname>Sprint</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue id="60">Sprint 1</customfieldvalue>

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