<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 03:10:02 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-5842] Exceptions thrown in scripting/engine_spidermonkey.cpp need to be handled there</title>
                <link>https://jira.mongodb.org/browse/SERVER-5842</link>
                <project id="10000" key="SERVER">Core Server</project>
                    <description>&lt;p&gt;There are a few cases where a &quot;native&quot; JavaScript function implemented in scripting/engine_spidermonkey.cpp or scripting/sm_db.cpp will throw an exception.  An example (currently) is the native_print() function which calls Convertor::toString() which can throw an exception.  If this exception isn&apos;t caught before control passes out through SpiderMonkey then SpiderMonkey is left in a corrupted state and attempts to use JavaScript after this, even to display the shell&apos;s prompt, will generate access violations (segfaults).&lt;/p&gt;

&lt;p&gt;We need to use try/catch around any exceptions that can be thrown within engine_spidermonkey.cpp and return normally (usually with JS_FALSE) so that SpiderMonkey can maintain its state properly.&lt;/p&gt;</description>
                <environment></environment>
        <key id="38702">SERVER-5842</key>
            <summary>Exceptions thrown in scripting/engine_spidermonkey.cpp need to be handled there</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="tad">Tad Marshall</assignee>
                                    <reporter username="tad">Tad Marshall</reporter>
                        <labels>
                    </labels>
                <created>Mon, 14 May 2012 23:25:47 +0000</created>
                <updated>Wed, 3 Jan 2018 03:45:28 +0000</updated>
                            <resolved>Wed, 30 May 2012 19:04:37 +0000</resolved>
                                                    <fixVersion>2.1.2</fixVersion>
                                    <component>Shell</component>
                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="124689" author="auto" created="Thu, 31 May 2012 13:15:59 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;tadmarshall&apos;, u&apos;name&apos;: u&apos;Tad Marshall&apos;, u&apos;email&apos;: u&apos;tad@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5842&quot; title=&quot;Exceptions thrown in scripting/engine_spidermonkey.cpp need to be handled there&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5842&quot;&gt;&lt;del&gt;SERVER-5842&lt;/del&gt;&lt;/a&gt; don&apos;t assert on call inside native_helper&lt;/p&gt;

&lt;p&gt;The native_helper() routine in engine_spidermonkey.cpp calls&lt;br/&gt;
functions that use Boost, and Boost will throw std:exceptions&lt;br/&gt;
on cases such as file and directory protection errors, badly&lt;br/&gt;
formed filenames, and others, so we can&apos;t call fassertFailed&lt;br/&gt;
on these exceptions; they are user errors and need to be passed&lt;br/&gt;
back to the JavaScript caller.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/d0e8e4f665c69e2ee384c0828457038d40b1498e&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/d0e8e4f665c69e2ee384c0828457038d40b1498e&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="124547" author="auto" created="Wed, 30 May 2012 21:46:36 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;tadmarshall&apos;, u&apos;name&apos;: u&apos;Tad Marshall&apos;, u&apos;email&apos;: u&apos;tad@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5842&quot; title=&quot;Exceptions thrown in scripting/engine_spidermonkey.cpp need to be handled there&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5842&quot;&gt;&lt;del&gt;SERVER-5842&lt;/del&gt;&lt;/a&gt; &amp;#8211; catch SocketExceptions, handle as non-fatal&lt;/p&gt;

&lt;p&gt;For selected functions, catch SocketExceptions and pass them&lt;br/&gt;
to JavaScript instead of calling fassertFailed.  Starting with&lt;br/&gt;
a small set of functions, we may need to add others later.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/d54bc803f9226b57a7eb58f07f856beb361fb658&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/d54bc803f9226b57a7eb58f07f856beb361fb658&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="124449" author="auto" created="Wed, 30 May 2012 18:30:46 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;tadmarshall&apos;, u&apos;name&apos;: u&apos;Tad Marshall&apos;, u&apos;email&apos;: u&apos;tad@10gen.com&apos;}
&lt;p&gt;Message: &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5842&quot; title=&quot;Exceptions thrown in scripting/engine_spidermonkey.cpp need to be handled there&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5842&quot;&gt;&lt;del&gt;SERVER-5842&lt;/del&gt;&lt;/a&gt; don&apos;t let exceptions leave engine_spidermonkey.cpp&lt;/p&gt;

&lt;p&gt;In every routine called by SpiderMonkey, use try/catch to grab all&lt;br/&gt;
AssertionException C++ exceptions and translate them into JavaScript&lt;br/&gt;
exceptions.  Catch all std::exceptions, log them and then fassert.&lt;br/&gt;
Some error handling was made a bit more user friendly, e.g. showing&lt;br/&gt;
correct syntax instead of saying &quot;invalid syntax&quot;.  Some C-style&lt;br/&gt;
casting was changed to static_cast or reinterpret_cast.  Some&lt;br/&gt;
JSClass structures were formatted for readability.  Some long lines&lt;br/&gt;
were reformatted.  The order of some tests were changed so that we&lt;br/&gt;
test for invalid arguments before we start allocating memory.  Some&lt;br/&gt;
existing try/catch code was changed to use a single try/catch over&lt;br/&gt;
the entire routine, but others were made nested in order to&lt;br/&gt;
preserve existing error messages that may be important to Buildbot&lt;br/&gt;
tests.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/72e14b4afbb2777281eb0c40612596ed1223730e&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/72e14b4afbb2777281eb0c40612596ed1223730e&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="123466" author="auto" created="Sun, 27 May 2012 17:54:58 +0000"  >&lt;p&gt;Author:&lt;/p&gt;
{u&apos;login&apos;: u&apos;tadmarshall&apos;, u&apos;name&apos;: u&apos;Tad Marshall&apos;, u&apos;email&apos;: u&apos;tad@10gen.com&apos;}
&lt;p&gt;Message: Code cleanup prior to fixing &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5842&quot; title=&quot;Exceptions thrown in scripting/engine_spidermonkey.cpp need to be handled there&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5842&quot;&gt;&lt;del&gt;SERVER-5842&lt;/del&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make three injected native JavaScript routines static since they are&lt;br/&gt;
not referenced outside this file.  Name them according to the convention&lt;br/&gt;
in engine_spidermonkey.cpp.  Use uassert consistently.  Make (user) error&lt;br/&gt;
messages correct, consistent and informative.&lt;br/&gt;
Branch: master&lt;br/&gt;
&lt;a href=&quot;https://github.com/mongodb/mongo/commit/0735336834dd9e55a62c6ce6baa0b1b525d7bd65&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://github.com/mongodb/mongo/commit/0735336834dd9e55a62c6ce6baa0b1b525d7bd65&lt;/a&gt;&lt;/p&gt;</comment>
                            <comment id="121872" author="tad" created="Tue, 22 May 2012 14:14:48 +0000"  >&lt;p&gt;After researching JavaScript exceptions in the SpiderMonkey code and online (Mozilla) documentation I learned that the JS_ReportError() function that we call from some places actually creates a JavaScript exception that can be caught with a JavaScript try/catch.  This seems like the right way to handle all errors in JavaScript that are not fatal MongoDB conditions.  Incorrect use of (for example) BSON objects created in JavaScript should be handled by sending a JavaScript exception to the code that caused it (by using JS_ReportError()) and should not be treated as MongoDB exceptions.  Following this approach throughout engine_spidermonkey.cpp and sm_db.cpp should eliminate the crashing problems we&apos;ve seen following JavaScript failures.&lt;/p&gt;</comment>
                            <comment id="121023" author="tad" created="Fri, 18 May 2012 16:47:57 +0000"  >&lt;p&gt;Moving from 2.3.0 to 2.1.2 because I resolved &lt;a href=&quot;https://jira.mongodb.org/browse/SERVER-5482&quot; title=&quot;array access attempt after a find failure puts shell in an unusable state&quot; class=&quot;issue-link&quot; data-issue-key=&quot;SERVER-5482&quot;&gt;&lt;del&gt;SERVER-5482&lt;/del&gt;&lt;/a&gt; (scheduled for 2.1.2) as a duplicate of this ticket.  Any uassert, verify or throw inside of engine_spidermonkey.cpp or sm_db.cpp that isn&apos;t caught will make SpiderMonkey unusable.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10011">
                    <name>Depends</name>
                                                                <inwardlinks description="is depended on by">
                                        <issuelink>
            <issuekey id="38247">SERVER-5796</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10010">
                    <name>Duplicate</name>
                                                                <inwardlinks description="is duplicated by">
                                        <issuelink>
            <issuekey id="16738">SERVER-3060</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="30193">SERVER-4913</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="35321">SERVER-5482</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10012">
                    <name>Related</name>
                                            <outwardlinks description="related to">
                                        <issuelink>
            <issuekey id="40036">SERVER-5967</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="12759">SERVER-1613</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                <customfield id="customfield_10050" key="com.atlassian.jira.toolkit:comments">
                        <customfieldname># Replies</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>6.0</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        <customfield id="customfield_10011" key="com.atlassian.jira.plugin.system.customfieldtypes:radiobuttons">
                        <customfieldname>Backwards Compatibility</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10038"><![CDATA[Fully Compatible]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                    <customfield id="customfield_13552" key="com.go2group.jira.plugin.crm:crm_generic_field">
                        <customfieldname>Case</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue><![CDATA[[500A000000UaSaKIAV]]]></customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                            <customfield id="customfield_10055" key="com.atlassian.jira.ext.charting:firstresponsedate">
                        <customfieldname>Date of 1st Reply</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>Sun, 27 May 2012 17:54:58 +0000</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10052" key="com.atlassian.jira.toolkit:dayslastcommented">
                        <customfieldname>Days since reply</customfieldname>
                        <customfieldvalues>
                                        11 years, 37 weeks, 6 days 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_11151" key="com.atlassian.jira.toolkit:LastCommentDate">
                        <customfieldname>Last public comment date</customfieldname>
                        <customfieldvalues>
                            11 years, 37 weeks, 6 days 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_10032" key="com.atlassian.jira.plugin.system.customfieldtypes:select">
                        <customfieldname>Operating System</customfieldname>
                        <customfieldvalues>
                                <customfieldvalue key="10026"><![CDATA[ALL]]></customfieldvalue>

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

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

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>9259</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|hsztzj:</customfieldvalue>

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