CouchDB
  1. CouchDB
  2. COUCHDB-577

couchdb @ winxp: Simple RegExp's can not be executed

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.10, 0.11
    • Fix Version/s: 1.1.1, 1.2
    • Component/s: JavaScript View Server
    • Labels:
      None
    • Environment:

      WinXP, setup-couchdb-0.11.0b880589.exe, setup-couchdb-0.10.0.exe

    • Skill Level:
      Regular Contributors Level (Easy to Medium)

      Description

      This show function failed on WinXP but pass on Linux:

      function (doc, req)

      { var rr2 = new RegExp("\n"); rr2.exec("fafdadsds"); var rr = /\n/; rr.exec("fafdadsds"); return "ok"; }

      The first RegExp is ok, but the second one (simple form) can not be executed.

      1> [debug] [<0.73.0>] 'GET' /c2/_design/dash/_show/overview

      {1,1}

      Headers: [

      {'Accept',"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"}

      ,

      {'Accept-Charset',"ISO-8859-1,utf-8;q=0.7,*;q=0.7"}

      ,

      {'Accept-Encoding',"gzip,deflate"}

      ,

      {'Accept-Language',"de-de,de;q=0.8,en-us;q=0.5,en;q=0.3"}

      ,

      {'Cache-Control',"max-age=0"}

      ,

      {'Connection',"keep-alive"}

      ,

      {'Host',"127.0.0.1:5984"}

      ,

      {'Keep-Alive',"300"}

      ,

      {'User-Agent',"Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 (.NET CLR 3.5.30729)"}

      ]
      1> [debug] [<0.73.0>] OAuth Params: []
      1> [info] [<0.98.0>] OS Process :: function raised error: TypeError: rr.exec is not a function
      1> [info] [<0.98.0>] OS Process :: stacktrace: (null,[object Object])@:4
      runShow(function (doc, req)

      {var rr2 = new RegExp("\n");rr2.exec("fafdadsds");var rr = /\n/;rr.exec("fafdadsds");return "ok";}

      ,null,[object Object],"function (doc, req)

      {\n var rr2 = new RegExp(\"\\n\");\n rr2.exec(\"fafdadsds\");\n var rr = /\\n/;\n rr.exec(\"fafdadsds\");\n\n return \"ok\";\n}

      \n\n")@../share/couchdb/server/main.js:388
      ("function (doc, req)

      {\n var rr2 = new RegExp(\"\\n\");\n rr2.exec(\"fafdadsds\");\n var rr = /\\n/;\n rr.exec(\"fa fdadsds\");\n\n return \"ok\";\n}

      \n\n",null,[object Object])@../share/couchdb/server/main.js:358
      @../share/couchdb/server/main.js:842

        Activity

        Thomas Mohaupt created issue -
        Hide
        Mark Hammond added a comment -

        I can only guess this is due to a difference in spidermonkey versions used by the Linux and Windows builds.

        Show
        Mark Hammond added a comment - I can only guess this is due to a difference in spidermonkey versions used by the Linux and Windows builds.
        Hide
        Roger Binns added a comment -

        I get exactly the same problem with the stock CouchDB 0.10 as shipped on Ubuntu 9.10. At least now I know I am not going mad. Even more perplexing the issue does no appear if I invoke CouchJS directly on my code and test data but does occur when using as view/list/show function.

        Show
        Roger Binns added a comment - I get exactly the same problem with the stock CouchDB 0.10 as shipped on Ubuntu 9.10. At least now I know I am not going mad. Even more perplexing the issue does no appear if I invoke CouchJS directly on my code and test data but does occur when using as view/list/show function.
        Paul Joseph Davis made changes -
        Field Original Value New Value
        Skill Level Regular Contributors Level (Easy to Medium)
        Hide
        Bob Clary added a comment -

        I see this with list functions on couchdb 1.0.1 built on Centos 5 64bit using the current Gecko 1.9.2 version of SpiderMonkey and R14B of Erlang.

        Show
        Bob Clary added a comment - I see this with list functions on couchdb 1.0.1 built on Centos 5 64bit using the current Gecko 1.9.2 version of SpiderMonkey and R14B of Erlang.
        Hide
        Jim Blomo added a comment -

        I can reproduce with Ubuntu Lucid:
        xulrunner-1.9.2 1.9.2.13+build3+nobinonly-0ubuntu0.10.04.1
        couchdb 0.10.0-1ubuntu2

        I worked around it by using the String.match(regex) function instead.

        Show
        Jim Blomo added a comment - I can reproduce with Ubuntu Lucid: xulrunner-1.9.2 1.9.2.13+build3+nobinonly-0ubuntu0.10.04.1 couchdb 0.10.0-1ubuntu2 I worked around it by using the String.match(regex) function instead.
        Hide
        Chas Emerick added a comment -

        Confirmed in Couchbase single 1.1.3 on OS X; clearly not an issue just on windows.

        Show
        Chas Emerick added a comment - Confirmed in Couchbase single 1.1.3 on OS X; clearly not an issue just on windows.
        Hide
        Paul Joseph Davis added a comment -

        @Chas

        Do you know what version of SpiderMonkey that couchbase package is using?

        Show
        Paul Joseph Davis added a comment - @Chas Do you know what version of SpiderMonkey that couchbase package is using?
        Hide
        Chas Emerick added a comment -

        @davisp

        No; if you know how to obtain that info, I'd be more than happy to find out. `couchjs -V` only responds with `1.1.3` (the rev of the couchbase build). Perhaps there's a clever way to get a version indicator from libmozjs, but I don't know how.

        I downloaded the latest spidermonkey js REPL, and it seems to do just fine with regex literals. Surely something so foundational couldn't be broken in the js engine used in Mozilla for years? (…he asks naively…)

        Show
        Chas Emerick added a comment - @davisp No; if you know how to obtain that info, I'd be more than happy to find out. `couchjs -V` only responds with `1.1.3` (the rev of the couchbase build). Perhaps there's a clever way to get a version indicator from libmozjs, but I don't know how. I downloaded the latest spidermonkey js REPL, and it seems to do just fine with regex literals. Surely something so foundational couldn't be broken in the js engine used in Mozilla for years? (…he asks naively…)
        Hide
        Paul Joseph Davis added a comment -

        @Chas

        Most likely there's some option that SpiderMonkey has that affects the way that RegEx initializers work. I'll do a bit of looking but the SM docs aren't broken up between versions very well.

        Show
        Paul Joseph Davis added a comment - @Chas Most likely there's some option that SpiderMonkey has that affects the way that RegEx initializers work. I'll do a bit of looking but the SM docs aren't broken up between versions very well.
        Hide
        Chas Emerick added a comment - - edited

        A fellow in Mozilla irc (thanks evilpie!) helped me determine the version of spidermonkey in use from the binary, using:

        strings libmozjs.dylib | grep "JavaScript-C"

        The result for my Couchbase Single install that exhibits this problem was:

        JavaScript-C 1.8.0 pre-release 1 2007-10-03

        The reaction to that was that "this version is really old".

        I haven't been following the relevant discussions too closely, but it sounds like upgrading spidermonkey 1.8.5 is a breaking change that is waiting on some newer version of couchdb. In any case, it seems like a dependency upgrade is the only way forward, i.e. it doesn't sound like there are any simple options to twiddle.

        Show
        Chas Emerick added a comment - - edited A fellow in Mozilla irc (thanks evilpie!) helped me determine the version of spidermonkey in use from the binary, using: strings libmozjs.dylib | grep "JavaScript-C" The result for my Couchbase Single install that exhibits this problem was: JavaScript-C 1.8.0 pre-release 1 2007-10-03 The reaction to that was that "this version is really old". I haven't been following the relevant discussions too closely, but it sounds like upgrading spidermonkey 1.8.5 is a breaking change that is waiting on some newer version of couchdb . In any case, it seems like a dependency upgrade is the only way forward, i.e. it doesn't sound like there are any simple options to twiddle.
        Hide
        Randall Leeds added a comment -

        CouchDB 1.1.1, which is currently being finalized, contains support for 1.8.5.

        Show
        Randall Leeds added a comment - CouchDB 1.1.1, which is currently being finalized, contains support for 1.8.5.
        Hide
        Chas Emerick added a comment -

        @Randall

        What's odd is that some couch distributions already use 1.8.5, or some flavor of it. e.g. Ubuntu since natty:

        http://packages.ubuntu.com/natty/couchdb-bin

        Given what I've read, in e.g. COUCHDB-1302, that shouldn't work, but it does…

        Show
        Chas Emerick added a comment - @Randall What's odd is that some couch distributions already use 1.8.5, or some flavor of it. e.g. Ubuntu since natty: http://packages.ubuntu.com/natty/couchdb-bin Given what I've read, in e.g. COUCHDB-1302 , that shouldn't work, but it does…
        Hide
        Randall Leeds added a comment -

        If you look in the Ubuntu changelog for that package, you can see that Chris Coulson applied downstream patches to CouchDB. The initial work to support the newer SpiderMonkey was based off his patches.

        Show
        Randall Leeds added a comment - If you look in the Ubuntu changelog for that package, you can see that Chris Coulson applied downstream patches to CouchDB. The initial work to support the newer SpiderMonkey was based off his patches.
        Hide
        Paul Joseph Davis added a comment -

        @Chas,

        The issue is that "SpiderMonkey 1.8.5" means about squat in the real life. There's a revision in trunk that removes the JSOPTION_ANONFUNFIX option for contexts which breaks all the things. The "SpiderMonkey 1.8.5 from the tarball on ftp.mozilla.org" does work with CouchDB. And there's a patch waiting for a couple tests that'll prevent couchdb from building if it finds a SpiderMonkey that doesn't have the anonfunfix thing.

        Also, that 1.8.0 version is actually not as old as the 1.7 that's still used in lots of places.

        Show
        Paul Joseph Davis added a comment - @Chas, The issue is that "SpiderMonkey 1.8.5" means about squat in the real life. There's a revision in trunk that removes the JSOPTION_ANONFUNFIX option for contexts which breaks all the things. The "SpiderMonkey 1.8.5 from the tarball on ftp.mozilla.org" does work with CouchDB. And there's a patch waiting for a couple tests that'll prevent couchdb from building if it finds a SpiderMonkey that doesn't have the anonfunfix thing. Also, that 1.8.0 version is actually not as old as the 1.7 that's still used in lots of places.
        Hide
        Dave Cottlehuber added a comment -

        I think this can be closed now; using 1.8.5 in CouchDB 1.1.1 fixes this on Windows. Thanks to PPaul on IRC for checking this.

        Show
        Dave Cottlehuber added a comment - I think this can be closed now; using 1.8.5 in CouchDB 1.1.1 fixes this on Windows. Thanks to PPaul on IRC for checking this.
        Hide
        Randall Leeds added a comment -

        Fixed since SpiderMonkey 1.8.5 support landed in 1.2 (r1137464 and r1164346) and was backport to 1.1.1 (r1166525).

        Show
        Randall Leeds added a comment - Fixed since SpiderMonkey 1.8.5 support landed in 1.2 (r1137464 and r1164346) and was backport to 1.1.1 (r1166525).
        Randall Leeds made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Fix Version/s 1.2 [ 12315198 ]
        Fix Version/s 1.1.1 [ 12316395 ]
        Resolution Fixed [ 1 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Thomas Mohaupt
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development