<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 02:54:24 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>[SERVER-529] exception while multiple threads exist can cause shell crash</title>
                <link>https://jira.mongodb.org/browse/SERVER-529</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;I&apos;ve written the multi thread testing code in the shell to avoid producing this bug, so it&apos;s low priority.  Here&apos;s what happens:&lt;/p&gt;

&lt;p&gt;Program received signal EXC_BAD_ACCESS, Could not access memory.&lt;br/&gt;
Reason: KERN_PROTECTION_FAILURE at address: 0x00000010&lt;br/&gt;
&lt;span class=&quot;error&quot;&gt;&amp;#91;Switching to process 67102 thread 0x2103&amp;#93;&lt;/span&gt;&lt;br/&gt;
0x0021c789 in v8::internal::ThreadManager::EagerlyArchiveThread ()&lt;br/&gt;
(gdb) r&lt;br/&gt;
The program being debugged has been started already.&lt;br/&gt;
Start it from the beginning? (y or n) n&lt;br/&gt;
Program not restarted.&lt;br/&gt;
(gdb) bt&lt;br/&gt;
#0  0x0021c789 in v8::internal::ThreadManager::EagerlyArchiveThread ()&lt;br/&gt;
#1  0xb0103000 in ?? ()&lt;br/&gt;
Cannot access memory at address 0xc0000007&lt;/p&gt;

&lt;p&gt;(Here using optimized (non debug) v8, but this bug is easy to reproduce.)&lt;/p&gt;

&lt;p&gt;To reproduce:&lt;/p&gt;

&lt;p&gt;diff --git a/shell/utils.js b/shell/utils.js&lt;br/&gt;
index 9671545..b53f0f5 100644&lt;br/&gt;
&amp;#8212; a/shell/utils.js&lt;br/&gt;
+++ b/shell/utils.js&lt;br/&gt;
@@ -387,6 +387,7 @@ if ( typeof _threadInject != &quot;undefined&quot; ){&lt;br/&gt;
     }&lt;/p&gt;

&lt;p&gt;     EventGenerator.prototype.addInsert = function( obj ) &lt;/p&gt;
{
+        this._add( &quot;assert( false )&quot; );
         this._add( &quot;t.insert( &quot; + tojson( obj ) + &quot; )&quot; );
     }

&lt;p&gt;@@ -562,11 +563,12 @@ if ( typeof _threadInject != &quot;undefined&quot; ){&lt;/p&gt;

&lt;p&gt;         runners.forEach( function( x ) &lt;/p&gt;
{ x.start(); }
&lt;p&gt; );&lt;br/&gt;
         var nFailed = 0;&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;runners.forEach( function( x ) 
&lt;div class=&quot;error&quot;&gt;&lt;span class=&quot;error&quot;&gt;Unknown macro: { if( !x.returnData() ) { ++nFailed; } } );&lt;br/&gt;
-        &lt;br/&gt;
-        // v8 doesn&apos;t like it if we assert before all threads are joined.  For now&lt;br/&gt;
-        // just avoid that possibility by asserting after threads are joined.&lt;br/&gt;
-        assert.eq( 0, nFailed, msg );&lt;br/&gt;
+        runners.forEach( function( x ) { assert( x.returnData() ); } );&lt;br/&gt;
+//        runners.forEach( function( x ) { if( !x.returnData() ) { ++nFailed; } }&lt;/span&gt; &lt;/div&gt;
&lt;p&gt;+//        &lt;br/&gt;
+//        // v8 doesn&apos;t like it if we assert before all threads are joined.  For n&lt;br/&gt;
+//        // just avoid that possibility by asserting after threads are joined.&lt;br/&gt;
+//        assert.eq( 0, nFailed, msg );&lt;br/&gt;
     }&lt;br/&gt;
 }&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;and run ./mongo jstests/parallel/insert.js&lt;/p&gt;</description>
                <environment></environment>
        <key id="11104">SERVER-529</key>
            <summary>exception while multiple threads exist can cause shell crash</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="4" iconUrl="https://jira.mongodb.org/images/icons/priorities/minor.svg">Minor - P4</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="2">Won&apos;t Fix</resolution>
                                        <assignee username="aaron">Aaron Staple</assignee>
                                    <reporter username="aaron">Aaron Staple</reporter>
                        <labels>
                    </labels>
                <created>Mon, 11 Jan 2010 12:53:58 +0000</created>
                <updated>Mon, 19 May 2014 22:08:05 +0000</updated>
                            <resolved>Tue, 12 Jan 2010 21:35:23 +0000</resolved>
                                                                    <component>Tools</component>
                                        <votes>0</votes>
                                    <watches>2</watches>
                                                                                                                <comments>
                            <comment id="11738" author="auto" created="Tue, 12 Jan 2010 21:48:14 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Aaron&apos;, &apos;email&apos;: &apos;aaron@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-529&quot; title=&quot;exception while multiple threads exist can cause shell crash&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-529&quot;&gt;&lt;del&gt;SERVER-529&lt;/del&gt;&lt;/a&gt; comment&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo/commit/2652e7faad43dc3c8fc57479dbf88ae16a7b6eab&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo/commit/2652e7faad43dc3c8fc57479dbf88ae16a7b6eab&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="11737" author="aaron" created="Tue, 12 Jan 2010 21:45:29 +0000"  >&lt;p&gt;Ran another test &amp;amp; it seems to confirm that the problem is as I described.&lt;/p&gt;</comment>
                            <comment id="11736" author="aaron" created="Tue, 12 Jan 2010 21:40:49 +0000"  >&lt;p&gt;Sorry, that part about &quot;threads in v8&quot; should be &quot;threads in boost...boost interface&quot;&lt;/p&gt;</comment>
                            <comment id="11734" author="aaron" created="Tue, 12 Jan 2010 21:35:23 +0000"  >&lt;p&gt;So I&apos;m pretty certain what&apos;s happening is as follows: The assertion causes the shell to exit, and on exit v8 starts shutting down (perhaps static objects are destoryed).  While this is going on, some of the js threads are still running and they make calls to a partially destroyed v8 engine, resulting in internal v8 assertions and memory errors.&lt;/p&gt;

&lt;p&gt;Threads in v8 can&apos;t be killed outright (at least not using the v8 interface, maybe it would be possible using a native pthread handle).  They can only be interrupted at programmatically defined interruption points.  Since a js thread could be in a js only loop at the time an interrupt is requested, so there&apos;s no way to interrupt threads in a timely manner in all cases using c++.  (There may be a way to implement a js interrupt/timeout, but I haven&apos;t investigated.)&lt;/p&gt;

&lt;p&gt;A best effort implementation to avoid this bug would be to issue a c++ interrupt on all threads, then wait for them all to finish, and exit if the wait times out.  Given that this bug is confined to testing scenarios, I don&apos;t think it&apos;s worth it to even do that.&lt;/p&gt;</comment>
                            <comment id="11731" author="auto" created="Tue, 12 Jan 2010 21:04:29 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{&apos;name&apos;: &apos;Aaron&apos;, &apos;email&apos;: &apos;aaron@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-529&quot; title=&quot;exception while multiple threads exist can cause shell crash&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-529&quot;&gt;&lt;del&gt;SERVER-529&lt;/del&gt;&lt;/a&gt; when js thread throws an exception, log and check return&lt;br/&gt;
&lt;a href=&quot;http://github.com/mongodb/mongo/commit/386a525c2fc299aeec3943143d5ff04783b4298c&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://github.com/mongodb/mongo/commit/386a525c2fc299aeec3943143d5ff04783b4298c&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="11708" author="aaron" created="Mon, 11 Jan 2010 14:37:44 +0000"  >&lt;p&gt;Also, to clarify, the threads here are JS shell threads created with fork(), new Thread(), etc.  These are only used to implement tests currently.&lt;/p&gt;</comment>
                            <comment id="11697" author="aaron" created="Mon, 11 Jan 2010 12:54:32 +0000"  >&lt;p&gt;Note The &apos;exception&apos; referred to here is a javascript exception.&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>7.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Tue, 12 Jan 2010 21:04:29 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        14 years, 6 weeks, 1 day ago
    
                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_18254" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Dependencies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[]]></customfieldvalue>


                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_10057" key="com.atlassian.jira.toolkit:lastusercommented">
                        <customfieldname>Last comment by Customer</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>true</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_10056" key="com.atlassian.jira.toolkit:lastupdaterorcommenter">
                        <customfieldname>Last commenter</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>ian@mongodb.com</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            14 years, 6 weeks, 1 day ago
                        </customfieldvalues>
                    </customfield>
                                                                                                                        <customfield id="customfield_10000" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Old_Backport</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10000"><![CDATA[No]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                            <customfield id="customfield_10051" key="com.atlassian.jira.toolkit:participants">
                        <customfieldname>Participants</customfieldname>
                        <customfieldvalues>
                                        <customfieldvalue>aaron</customfieldvalue>
            <customfieldvalue>auto</customfieldvalue>
    
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                        <customfield id="customfield_14254" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Product Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hrpt5b:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrimq7:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>22334</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                            <customfield id="customfield_23361" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Requested By</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10053" key="com.atlassian.jira.ext.charting:timeinstatus">
                        <customfieldname>Time In Status</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_22870" key="com.onresolve.jira.groovy.groovyrunner:scripted-field">
                        <customfieldname>Triagers</customfieldname>
                        <customfieldvalues>
                                

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_14350" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>serverRank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>1|hsbyjz:</customfieldvalue>

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