<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:56:39 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>[JAVA-2228] Document.parse() stucked in a dead loop</title>
                <link>https://jira.mongodb.org/browse/JAVA-2228</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt;I use mongo java driver in my flume project, and one day the events channel was full and after debug, I found that the thread was blocked in a dead loop.&lt;br/&gt;
Below is the stacktrace:&lt;br/&gt;
********************************************************************************&lt;br/&gt;
	at org.bson.json.JsonScanner.scanRegularExpression(JsonScanner.java:190)&lt;br/&gt;
	at org.bson.json.JsonScanner.nextToken(JsonScanner.java:100)&lt;br/&gt;
	at org.bson.json.JsonReader.popToken(JsonReader.java:475)&lt;br/&gt;
	at org.bson.json.JsonReader.readBsonType(JsonReader.java:232)&lt;br/&gt;
	at org.bson.codecs.DocumentCodec.decode(DocumentCodec.java:139)&lt;br/&gt;
	at org.bson.codecs.DocumentCodec.decode(DocumentCodec.java:45)&lt;br/&gt;
	at org.bson.codecs.DocumentCodec.readValue(DocumentCodec.java:215)&lt;br/&gt;
	at org.bson.codecs.DocumentCodec.decode(DocumentCodec.java:141)&lt;br/&gt;
	at org.bson.codecs.DocumentCodec.decode(DocumentCodec.java:45)&lt;br/&gt;
	at org.bson.Document.parse(Document.java:105)&lt;br/&gt;
	at org.bson.Document.parse(Document.java:90)&lt;/p&gt;</description>
                <environment>&lt;br/&gt;
</environment>
        <key id="294340">JAVA-2228</key>
            <summary>Document.parse() stucked in a dead loop</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="ross@mongodb.com">Ross Lawley</assignee>
                                    <reporter username="lqp276">liqiaoping</reporter>
                        <labels>
                    </labels>
                <created>Thu, 16 Jun 2016 03:41:40 +0000</created>
                <updated>Wed, 19 Oct 2016 14:17:39 +0000</updated>
                            <resolved>Thu, 23 Jun 2016 11:17:37 +0000</resolved>
                                    <version>3.2.2</version>
                                    <fixVersion>3.3.0</fixVersion>
                                    <component>BSON</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="1303986" author="ross@10gen.com" created="Thu, 23 Jun 2016 11:17:37 +0000"  >&lt;p&gt;Thanks &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=lqp276&quot; class=&quot;user-hover&quot; rel=&quot;lqp276&quot;&gt;lqp276&lt;/a&gt; for reporting.&lt;/p&gt;

&lt;p&gt;A fix has now been merged into master and will be available in the forthcoming   3.3 release.&lt;/p&gt;</comment>
                            <comment id="1303985" author="xgen-internal-githook" created="Thu, 23 Jun 2016 11:15:37 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;rozza&apos;, u&apos;name&apos;: u&apos;Ross Lawley&apos;, u&apos;email&apos;: u&apos;ross.lawley@gmail.com&apos;}
&lt;p&gt;Message: Fix infinite loop when parsing invalid regular expressions&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2228&quot; title=&quot;Document.parse() stucked in a dead loop&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2228&quot;&gt;&lt;del&gt;JAVA-2228&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/d2c2cd75d202bec113d9cd6a03687c3645b379df&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/d2c2cd75d202bec113d9cd6a03687c3645b379df&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1299399" author="xgen-internal-githook" created="Mon, 20 Jun 2016 10:20:49 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;username&apos;: u&apos;rozza&apos;, u&apos;name&apos;: u&apos;Ross Lawley&apos;, u&apos;email&apos;: u&apos;ross.lawley@gmail.com&apos;}
&lt;p&gt;Message: Fix infinite loop when parsing invalid regular expressions.&lt;/p&gt;

&lt;p&gt;Added EOF check for JsonBuffer to prevent multiple reads at end of file.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;https://jira.mongodb.org/browse/JAVA-2228&quot; title=&quot;Document.parse() stucked in a dead loop&quot; class=&quot;issue-link&quot; data-issue-key=&quot;JAVA-2228&quot;&gt;&lt;del&gt;JAVA-2228&lt;/del&gt;&lt;/a&gt;&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo-java-driver/commit/c1a7906682b7fb58c3384c9a44665362ec363b3f&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo-java-driver/commit/c1a7906682b7fb58c3384c9a44665362ec363b3f&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="1297456" author="lqp276" created="Fri, 17 Jun 2016 02:00:11 +0000"  >&lt;p&gt;Hi Ross,&lt;br/&gt;
I am very glad to report and make mongo better. &lt;/p&gt;

&lt;p&gt;I agree with you analysis and the bug was triggerd by the  malfromed json string.  Because in our project simple json will sastify our needs we didn&apos;t import a third party json lib. I think it would be better to call it a &apos;robust issue&apos;, ^^&lt;br/&gt;
I followed the code of bson and I think is doesn&apos;t handle the End Of Stream properly, bellow code:&lt;/p&gt;

&lt;p&gt;in method &quot;scanRegularExpression&quot; of org.bson.json.JsonScanner:&lt;br/&gt;
....&lt;br/&gt;
        while (true) {&lt;br/&gt;
            int c = buffer.read();&lt;br/&gt;
            switch (state) { &lt;br/&gt;
.....&lt;br/&gt;
when buffer return -1 to mark the end, and the leading regex chars mark a &apos;In pattern&apos; context, the loop is dead and failed to report &quot;Invalid Regular Exception&quot;&lt;/p&gt;</comment>
                            <comment id="1296411" author="ross@10gen.com" created="Thu, 16 Jun 2016 12:40:57 +0000"  >&lt;p&gt;Hi &lt;a href=&quot;https://jira.mongodb.org/secure/ViewProfile.jspa?name=lqp276&quot; class=&quot;user-hover&quot; rel=&quot;lqp276&quot;&gt;lqp276&lt;/a&gt;,&lt;/p&gt;

&lt;p&gt;Thanks for the ticket, it looks to be an escaping issue as well as a &lt;tt&gt;Document.parse&lt;/tt&gt; issue.  In the example provided its caused by the value in &lt;tt&gt;mark&lt;/tt&gt;.&lt;/p&gt;

&lt;p&gt;A simplified failure case is:&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;   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;String json = &quot;{a: \&quot;\&quot;/b\&quot;}&quot;;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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-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;System.out.println(Document.parse(json)); &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;However, escaping correctly works as expected:&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;   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;String json = &quot;{a: \&quot;\\\&quot;/b\&quot;}&quot;;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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-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;System.out.println(Document.parse(json));&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;With the example string I ensured that the quote in the mark string is triple escaped and it works as expected:&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;   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;String json = &quot;{\&quot;addr\&quot;:\&quot;10.10.182.143\&quot;,\&quot;type\&quot;:1,\&quot;ver\&quot;:1,\&quot;terminal\&quot;:2,\&quot;ts\&quot;:1465995544485,\&quot;body\&quot;:{\&quot;step\&quot;:11216,&quot;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;                + &quot;\&quot;order\&quot;:\&quot;20160615205848203041\&quot;,\&quot;uid\&quot;:2050061709,\&quot;loss\&quot;:0,\&quot;rtt\&quot;:59,\&quot;fec\&quot;:0,\&quot;pnum\&quot;:14,&quot;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   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;                + &quot;\&quot;mark\&quot;:\&quot;\\u0001\\u01d8\\u001f\\ufffd\\ufffd\\ufffd\\ufffd\\\&quot;/\\ufffd\\ufffdP5\\u0005:0\&quot;}}&quot;;&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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;   width: auto; padding: 0;&quot;&gt;&amp;nbsp;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&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-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;System.out.println(Document.parse(json));&lt;/span&gt;&lt;/pre&gt;
			&lt;/td&gt;
		&lt;/tr&gt;
			&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p/&gt;</comment>
                            <comment id="1296122" author="lqp276" created="Thu, 16 Jun 2016 03:42:47 +0000"  >&lt;p&gt;The data should reproduce this bug:&lt;br/&gt;
{&quot;addr&quot;:&quot;10.10.182.143&quot;,&quot;type&quot;:1,&quot;ver&quot;:1,&quot;terminal&quot;:2,&quot;ts&quot;:1465995544485,&quot;body&quot;:{&quot;step&quot;:11216,&quot;order&quot;:&quot;20160615205848203041&quot;,&quot;uid&quot;:2050061709,&quot;loss&quot;:0,&quot;rtt&quot;:59,&quot;fec&quot;:0,&quot;pnum&quot;:14,&quot;mark&quot;:&quot;\u0001\u01d8\u001f\ufffd\ufffd\ufffd\ufffd&quot;/\ufffd\ufffdP5\u0005:0&quot;}}&lt;/p&gt;

&lt;p&gt;after Reading the code I think it&apos;s the bug of bson library&lt;span class=&quot;error&quot;&gt;&amp;#91;version bson-3.2.2.jar&amp;#93;&lt;/span&gt;, but I think it will better to raise this bug here...&lt;/p&gt;

&lt;p&gt;it&apos;s my first time to add bug, if i missed some important info please note me&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|hrdvi7:</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="1123">JVM Sprint 34</customfieldvalue>

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