antoniogarrote / rdfstore-js

JS RDF store with SPARQL support
MIT License
563 stars 109 forks source link

'too much recursion' error in Firefox #128

Open theofred opened 8 years ago

theofred commented 8 years ago

I use rdfstore for a client-side js application. It is part of a bigger app and it's only used to read a RDF-file and then converting it to an array.

This is the part in my code:

 init() {
     var endResult = new Array;
     this.rdfStore.create(function (err, store) {
       if(err) {
         console.log("problem with create");
       } else {
         console.log("rdfStore created");
         store.load('text/turtle', localRdfData, function(error, results){
           if(error) {
             console.log("load error");
           } else {
             store.execute("SELECT ?s ?p ?o WHERE { ?s ?p ?o}", function(success, results){
               endResult = results;
               console.log(endResult);
             });}});}});
     return endResult;
  }

This is the console output:

rdfStore created client.min.js:26993:12

too much recursion  client.min.js:37000:10
(here comes the stack-trace)-->
QuadIndex.prototype.insert/<()
 client.min.js:37000
Tree.prototype.__insertNonFull/<()
 client.min.js:37451
Tree.prototype._diskWrite/<()
 client.min.js:37170
nextTick()
 client.min.js:33855
Tree.prototype._diskWrite()
 client.min.js:37169
Tree.prototype.__insertNonFull()
 client.min.js:37450
Tree.prototype._insertNonFull()
 client.min.js:37410
Tree.prototype.insert()
 client.min.js:37397
QuadIndex.prototype.insert()
 client.min.js:36999
QuadBackend.prototype.index/<()
 client.min.js:59946
eachSeries/iterate()
 client.min.js:34203
nextTick()
 client.min.js:33855
eachSeries/iterate/<()
 client.min.js:34214
QuadBackend.prototype.index/</<()
 client.min.js:59947
QuadIndex.prototype.insert/<()
 client.min.js:37000
Tree.prototype.__insertNonFull/<()
 client.min.js:37451
Tree.prototype._diskWrite/<()
 client.min.js:37170
nextTick()
 client.min.js:33855
Tree.prototype._diskWrite()
 client.min.js:37169
Tree.prototype.__insertNonFull()
 client.min.js:37450
Tree.prototype._insertNonFull()
 client.min.js:37410
Tree.prototype.insert()
 client.min.js:37397
QuadIndex.prototype.insert()
 client.min.js:36999
QuadBackend.prototype.index/<()
 client.min.js:59946
eachSeries/iterate()
 client.min.js:34203
nextTick()
 client.min.js:33855
eachSeries/iterate/<()
 client.min.js:34214
QuadBackend.prototype.index/</<()
 client.min.js:59947
QuadIndex.prototype.insert/<()
 client.min.js:37000
Tree.prototype.__insertNonFull/<()
 client.min.js:37451
Tree.prototype._diskWrite/<()
 client.min.js:37170
nextTick()
 client.min.js:33855
Tree.prototype._diskWrite()
 client.min.js:37169
Tree.prototype.__insertNonFull()
 client.min.js:37450
Tree.prototype._insertNonFull()
 client.min.js:37410
Tree.prototype.insert()
 client.min.js:37397
QuadIndex.prototype.insert()
 client.min.js:36999
QuadBackend.prototype.index/<()
 client.min.js:59946
eachSeries/iterate()
 client.min.js:34203
nextTick()
 client.min.js:33855
eachSeries/iterate/<()
 client.min.js:34214
QuadBackend.prototype.index/</<()
 client.min.js:59947
QuadIndex.prototype.insert/<()
 client.min.js:37000
Tree.prototype.__insertNonFull/<()
 client.min.js:37451
Tree.prototype._diskWrite/<()
 client.min.js:37170
nextTick()
 client.min.js:33855
Tree.prototype._diskWrite()
 client.min.js:37169
Tree.prototype.__insertNonFull()
 client.min.js:37450
Tree.prototype._insertNonFull()
 client.min.js:37410
Tree.prototype.insert()
 client.min.js:37397
QuadIndex.prototype.insert()
 client.min.js:36999
QuadBackend.prototype.index/<()
 client.min.js:59946
eachSeries/iterate()
 client.min.js:34203
eachSeries()
 client.min.js:34219
QuadBackend.prototype.index()
 client.min.js:59944
QueryEngine.prototype.batchLoad/</</<()
 client.min.js:29527
QuadBackend.prototype.search/<()
 client.min.js:59966
QuadIndex.prototype.search/<()
 client.min.js:37011
Tree.prototype.__search()
 client.min.js:37235
Tree.prototype.search()
 client.min.js:37219
QuadIndex.prototype.search()
 client.min.js:37010
QuadBackend.prototype.search()
 client.min.js:59965
QueryEngine.prototype.batchLoad/</<()
 client.min.js:29525
eachSeries/iterate/<()
 client.min.js:34211
QueryEngine.prototype.batchLoad/registerComponent/</returnUriComponent()
 client.min.js:29467
QueryEngine.prototype.batchLoad/registerComponent/</<()
 client.min.js:29472
Lexicon.prototype.registerGraph()
 client.min.js:60275
QueryEngine.prototype.batchLoad/registerComponent/<()
 client.min.js:29471
Lexicon.prototype.registerUri()
 client.min.js:60307
QueryEngine.prototype.batchLoad/registerComponent()
 client.min.js:29460
QueryEngine.prototype.batchLoad/</<()
 client.min.js:29519
eachSeries/iterate()
 client.min.js:34203
nextTick()
 client.min.js:33855
eachSeries/iterate/<()
 client.min.js:34214
QueryEngine.prototype.batchLoad/registerComponent/<()
 client.min.js:29485
Lexicon.prototype.registerLiteral/</<()
 client.min.js:60446
seq/</<()
 client.min.js:34248
reduce/<()
 client.min.js:34230
eachSeries/iterate/<()
 client.min.js:34211
reduce/</<()
 client.min.js:34227
seq/</</<()
 client.min.js:34244
Lexicon.prototype.registerLiteral/</</<()
 client.min.js:60443
Tree.prototype.__insertNonFull/<()
 client.min.js:37451
Tree.prototype._diskWrite/<()
 client.min.js:37170
nextTick()
 client.min.js:33855
Tree.prototype._diskWrite()
 client.min.js:37169
Tree.prototype.__insertNonFull()
 client.min.js:37450
Tree.prototype._insertNonFull()
 client.min.js:37410
Tree.prototype.insert()
 client.min.js:37397
Lexicon.prototype.registerLiteral/</<()
 client.min.js:60442
seq/</<()
 client.min.js:34241
reduce/<()
 client.min.js:34225
eachSeries/iterate()
 client.min.js:34203
nextTick()
 client.min.js:33855
eachSeries/iterate/<()
 client.min.js:34214
reduce/</<()
 client.min.js:34227
seq/</</<()
 client.min.js:34244
Lexicon.prototype.registerLiteral/</</<()
 client.min.js:60439
Tree.prototype.__insertNonFull/<()
 client.min.js:37451
Tree.prototype._diskWrite/<()
 client.min.js:37170
nextTick()
 client.min.js:33855
Tree.prototype._diskWrite()
 client.min.js:37169
Tree.prototype.__insertNonFull()
 client.min.js:37450
Tree.prototype._insertNonFull()
 client.min.js:37410
Tree.prototype.insert()
 client.min.js:37397
Lexicon.prototype.registerLiteral/</<()
 client.min.js:60438
seq/</<()
 client.min.js:34241
reduce/<()
 client.min.js:34225
eachSeries/iterate()
 client.min.js:34203
eachSeries()
 client.min.js:34219
reduce()
 client.min.js:34224
seq/<()
 client.min.js:34240
Lexicon.prototype.registerLiteral/<()
 client.min.js:60437
Tree.prototype.__search()
 client.min.js:37235
Tree.prototype.search()
 client.min.js:37219
Lexicon.prototype.registerLiteral()
 client.min.js:60431
QueryEngine.prototype.batchLoad/registerComponent()
 client.min.js:29479
QueryEngine.prototype.batchLoad/</<()
 client.min.js:29519
eachSeries/iterate()
 client.min.js:34203
nextTick()
 client.min.js:33855
eachSeries/iterate/<()
 client.min.js:34214
QueryEngine.prototype.batchLoad/registerComponent/</returnUriComponent()
 client.min.js:29467
QueryEngine.prototype.batchLoad/registerComponent/<()
 client.min.js:29475
Lexicon.prototype.registerUri/</<()
 client.min.js:60324
seq/</<()
 client.min.js:34248
reduce/<()
 client.min.js:34230
eachSeries/iterate/<()
 client.min.js:34211
reduce/</<()
 client.min.js:34227

My system: Windows 7 Ultimate 64 Bit Firefox 47.0

also tested on: Ubuntu 14.04 Firefox 47.0

Windows 7 Pro 32 Bit Firefox 47.0

they all produced this error.

There is no error when Firefox is in safe-mode. But if Firefox is in normal-mode and all addons are disabled, the error is still there. So no addons fault. I also reseted my Firefox and started with a new profile but nothing worked.

nufercle commented 8 years ago

Just to note that I also encountered this problem.

The issue appears to be fixed in Firefox 48.

folkvir commented 6 years ago

The number of Maximum call stack is not the same in nodejs or in a browser (https://stackoverflow.com/a/7828803/6126329)

This also appears in nodejs when you are trying to run a query on huge number of data. async.whilst(function(){ ^ RangeError: Maximum call stack size exceeded

This can be fixed by fixing the whilst function in utils.js (see https://stackoverflow.com/a/20999077/6126329). This fix will let node or the browser free the stack when needed.

var whilst = function (test, iterator, callback) {
    if (test()) {
        iterator(function (err) {
            if (err) {
                return callback(err);
            }
            setTimeout(() => {
              whilst(test, iterator, callback)
            }, 0)
        });
    }
    else {
        callback();
    }
};

This fixed my problem.

miranda-zhang commented 6 years ago
Maximum call stack size exceeded
rdf_store_min_formated.js:3046 RangeError: Maximum call stack size exceeded
    at Function.map (jquery.min.js:2)
    at i (jquery.tmpl.min.js:1)
    at jquery.tmpl.min.js:1
    at Function.map (jquery.min.js:2)
    at i (jquery.tmpl.min.js:1)
    at Function.tmpl (jquery.tmpl.min.js:1)
    at ko.jqueryTmplTemplateEngine.renderTemplate (semko.min.js:96)
    at a (semko.min.js:82)
    at Object.ko.dependentObservable.disposeWhen [as read] (semko.min.js:84)
    at ko.subscription.f [as callback] (semko.min.js:42)

My rdf_store_min_formated.js

    $.RDFLoader.prototype.tryToParse = function(a, b, e, d) {
        try {
            if (typeof e === "string" && (e = s.normalizeUnicodeLiterals(e)),
            a.async)
                a.parse(e, b, d);
            else {
                var i = a.parse(e, b);
                i != null ? d(!0, i) : d(!1, "parsing error")
            }
        } catch (h) {
            console.log(h.message),//3045
            console.log(h.stack),//3046
            d(!1, "parsing error with mime type : " + h)
        }
    }
    ;

I modified this json-ld-macros example

I have about 5000 items/rows in my data.