You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2020/01/06 17:08:21 UTC

[couchdb] 01/01: Fix JS tests on SpiderMonkey 60

This is an automated email from the ASF dual-hosted git repository.

davisp pushed a commit to branch fix-view-errors-js-test
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 9b59225e575c192b03f035758600d2317bd62045
Author: Paul J. Davis <pa...@gmail.com>
AuthorDate: Mon Jan 6 11:06:40 2020 -0600

    Fix JS tests on SpiderMonkey 60
    
    It turns out the infinite loop can now run fast enough that we exhaust
    the stack space in a given couchjs process. This ends up leaving a
    couchjs process that can't be used for other things as the `map_results`
    buffer doesn't get reset inbetween calls.
---
 share/server/state.js                | 1 +
 share/server/views.js                | 4 ++++
 test/javascript/tests/view_errors.js | 4 ++--
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/share/server/state.js b/share/server/state.js
index ff553dd..76fb68b 100644
--- a/share/server/state.js
+++ b/share/server/state.js
@@ -16,6 +16,7 @@ var State = {
     State.funs = [];
     State.lib = null;
     State.query_config = config || {};
+    Views.reset();
     gc();
     print("true"); // indicates success
   },
diff --git a/share/server/views.js b/share/server/views.js
index 7c9953d..623f47d 100644
--- a/share/server/views.js
+++ b/share/server/views.js
@@ -56,6 +56,7 @@ var Views = (function() {
   };
 
   function handleViewError(err, doc) {
+    map_results = [];
     if (err == "fatal_error") {
       // Only if it's a "fatal_error" do we exit. What's a fatal error?
       // That's for the query to decide.
@@ -82,6 +83,9 @@ var Views = (function() {
 
   return {
     // view helper functions
+    reset : function() {
+        map_results = [];
+    },
     emit : function(key, value) {
       map_results.push([key, value]);
     },
diff --git a/test/javascript/tests/view_errors.js b/test/javascript/tests/view_errors.js
index 7577b80..94a0aab 100644
--- a/test/javascript/tests/view_errors.js
+++ b/test/javascript/tests/view_errors.js
@@ -145,7 +145,7 @@ couchTests.view_errors = function(debug) {
         _id:"_design/infinite",
         language: "javascript",
         views: {
-          "infinite_loop" :{map:"function(doc) {while(true){emit(doc,doc);}};"}
+          "infinite_loop" :{map:"function(doc) {while(true){};"}
         }
       };
       T(db.save(designDoc3).ok);
@@ -154,7 +154,7 @@ couchTests.view_errors = function(debug) {
           db.view("infinite/infinite_loop");
           T(0 == 1);
       } catch(e) {
-          T(e.error == "os_process_error" || e.error == "unnamed_error");
+          T(e.error == "os_process_error");
       }
 
       // Check error responses for invalid multi-get bodies.