This repository has been archived by the owner. It is now read-only.

call stack size fail when circular references and this.spy() #201

Closed
DimitarChristoff opened this Issue Jun 21, 2012 · 6 comments

Comments

Projects
None yet
3 participants
@DimitarChristoff

DimitarChristoff commented Jun 21, 2012

Basically - this test (a simplified version of the original classes):

buster.testCase('breaking call stack when using circular references and spies', {

    setUp: function() {

        var A = function() {
            this.collections = [];
        }, B = function() {
            this.models = [];
            this.add = function(what) {
                what.collections.push(this);
                this.models.push(what)
            };
        };


        this.model = new A();
        this.collection = new B();
    },

    'Expect a model.collections to receive the collection it is a member of': function() {
        var spy = this.spy();

        this.collection.add(this.model);
        Array.forEach(this.model.collections, spy);
        buster.assert.calledWith(spy, this.collection);
    }

});

in FF and Chrme, both of these fail with InternalError: too much recursion (FF) or RangeError: Maximum call stack size exceeded (Chrome)

when refactored to not use a spy, it passes fine.

when the circular reference is removed, it passes fine.

other deps which may or may not be relevant - mootools-core (standard), es5-shim.js - let me know if you cannot reproduce it. latest buster/sinon from npm updated this week.

@ghost ghost assigned cjohansen Jun 29, 2012

@cjohansen

This comment has been minimized.

Member

cjohansen commented Jul 5, 2012

I failed to reproduce. I first tried running on Node, where it said No method Array.forEach. Using this.model.collections.forEach worked fine.

In Firefox, it works fine with both the generic and specific versions of forEach.

@DimitarChristoff

This comment has been minimized.

DimitarChristoff commented Jul 6, 2012

i will retest this today against the latest beta i pulled. maybe my imac's 8gb ram are not enough :>

@DimitarChristoff

This comment has been minimized.

DimitarChristoff commented Jul 6, 2012

https://github.com/DimitarChristoff/buster-bug - clone this.

Chrome 20.0.1132.47, OS X 10.7 (Lion): E                                                                                
Firefox 13.0.1, OS X 10.7 (Lion):      E                                                                                
Error: Chrome 20.0.1132.47, OS X 10.7 (Lion) breaking call stack when using circular references and spies Expect a model.collections to receive the collection it is a member of
    RangeError: Maximum call stack size exceeded

Error: Firefox 13.0.1, OS X 10.7 (Lion) breaking call stack when using circular references and spies Expect a model.collections to receive the collection it is a member of
    InternalError: too much recursion

2 test cases, 2 tests, 0 assertions, 0 failures, 2 errors, 0 timeouts
WARNING: No assertions
Finished in 0.316s

the box:

> vm_stat 
Mach Virtual Memory Statistics: (page size of 4096 bytes)
Pages free:                          41107.
Pages active:                      1214898.
Pages inactive:                     573019.
Pages speculative:                    5650.
Pages wired down:                   260787.
"Translation faults":           1303498654.
Pages copy-on-write:             162700289.
Pages zero filled:               407288860.
Pages reactivated:                 2349122.
Pageins:                           3305748.
Pageouts:                           496252.
Object cache: 14 hits of 1888259 lookups (0% hit rate)
dchristoff@Dimitars-iMac:~/Projects/buster-bug (master):
> /usr/sbin/system_profiler SPHardwareDataType
Hardware:

    Hardware Overview:

      Model Name: iMac
      Model Identifier: iMac12,2
      Processor Name: Intel Core i5
      Processor Speed: 3.1 GHz
      Number of Processors: 1
      Total Number of Cores: 4
      L2 Cache (per Core): 256 KB
      L3 Cache: 6 MB
      Memory: 8 GB
      Boot ROM Version: IM121.0047.B0A
      SMC Version (system): 1.72f1
      Serial Number (system): C02FH1ZXDHJQ
      Hardware UUID: 7963DC90-B5DD-55B7-A5C7-F864A8B1458C

dchristoff@Dimitars-iMac:~/Projects/buster-bug (master):
> uname -a
Darwin Dimitars-iMac.local 11.0.0 Darwin Kernel Version 11.0.0: Sat Jun 18 12:56:35 PDT 2011; root:xnu-1699.22.73~1/RELEASE_X86_64 x86_64
@obray

This comment has been minimized.

obray commented Jul 6, 2012

oliverbray@Oliver-Brays-iMac:~/projects/buster-bug(master)$ /usr/sbin/system_profiler SPHardwareDataType
Hardware:

    Hardware Overview:

      Model Name: iMac
      Model Identifier: iMac11,3
      Processor Name: Intel Core i5
      Processor Speed: 2.8 GHz
      Number Of Processors: 1
      Total Number Of Cores: 4
      L2 Cache (per core): 256 KB
      L3 Cache: 8 MB
      Memory: 8 GB
      Processor Interconnect Speed: 4.8 GT/s
      Boot ROM Version: IM112.0057.B00
      SMC Version (system): 1.59f2
      Serial Number (system): W804401ZHJY
      Hardware UUID: 9CBAF35D-36D1-5689-97A3-15F27B5D9E5E

oliverbray@Oliver-Brays-iMac:~/projects/buster-bug(master)$ uname -a
Darwin Oliver-Brays-iMac.local 10.7.0 Darwin Kernel Version 10.7.0: Sat Jan 29 15:17:16 PST 2011; root:xnu-1504.9.37~1/RELEASE_I386 i386
oliverbray@Oliver-Brays-iMac:~/projects/buster-bug(master)$ buster-test -r specification
Chrome 20.0.1132.47, OS X 10.6 (Snow Leopard)
  ✖ breaking call stack when using circular references and spies Expect a model.collections to receive the collection it is a member of
    RangeError: Maximum call stack size exceeded
1 test case, 1 test, 0 assertions, 0 failures, 1 error, 0 timeouts
WARNING: No assertions
Finished in 0.015s
@DimitarChristoff

This comment has been minimized.

DimitarChristoff commented Jul 6, 2012

> buster test -r specification 
Internet Explorer 9.0, Windows 7
  ✖ breaking call stack when using circular references and spies Expect a model.collections to receive the collection it is a member of
    Error: Out of stack space
1 test case, 1 test, 0 assertions, 0 failures, 1 error, 0 timeouts

> buster test -r specification 
Firefox 12.0, Windows 7
  ✖ breaking call stack when using circular references and spies Expect a model.collections to receive the collection it is a member of
    InternalError: too much recursion
1 test case, 1 test, 0 assertions, 0 failures, 1 error, 0 timeouts
WARNING: No assertions

it's not browser specific, seems to break in all. I am running latest buster codebase i installed via npm yesterday

@cjohansen

This comment has been minimized.

Member

cjohansen commented Jul 9, 2012

@cjohansen cjohansen closed this Jul 9, 2012

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.