Results 1 to 3 of 3

Thread: Reliance on arguments object aliasing leads to intermittent exceptions

    This issue duplicates another issue.
  1. #1
    Sencha Premium Member
    Join Date
    Sep 2011
    Posts
    51
    Vote Rating
    2
      0  

    Default Reliance on arguments object aliasing leads to intermittent exceptions

    I believe there may be a Chrome V8 issue here, and I've already reported to Chrome V8; however, given that a number of Ext users are probably affected by this, you may want to modify Ext code to insulate yourselves. Here's the issue...

    Occasionally, during application load, an exception is thrown from Ext.container.AbstractContainer.get: specifically, by the following test:
    if (item.floating) {


    The problem is that every once in a while, "item" is undefined. The offending item invariably corresponds to one of the toolbar items that can be specified in a config as "-", "->", etc... Upon entry into the add method, the item is always one of the permissible strings. The array containing these strings (and other configs) is passed to prepareItems, which invokes lookupComponent on each. Ext.toolbar.Toolbar.lookupComponent is where the shortcut string would typically be mapped to the corresponding component config (e.g., { xtype: 'tbseparator' }), and a call to the parent lookupComponent would actually create the component. The problem occurs in lookupComponent's call to callParent, which is responsible for passing the new config object up the inheritance chain. It relies upon Javascript's aliasing of formal parameters to the special (and sometimes quirky) arguments object. Essentially, it reassigns the formal parameter within the body of the method and assumes that the reassignment affects the corresponding element within arguments object (in this case arguments[0]). Since a value is always provided for the input parameter, it seems that this *should* work, and in fact, it *almost* always does. Every once in a while, however, arguments[] is not updated by the assignment to the formal parameter. When this happens, the shortcut string (e.g., "tbfill") - not the config object - is passed to the parent method via callParent. This causes the parent method to call Ext.ComponentManager.get instead of Ext.ComponentManager.create, which ultimately leads to a doomed attempt to find "-", "->", or whatever it happens to be in an id map, which produces the undefined value responsible for the exception.


    Solution: Don't depend upon JS' aliasing of arguments object to formal parameters. While the Ext code should work as written, there are clearly some browser-specific dark corners here, and it's just as easy to use the formal parameter directly: e.g., in Ext.toolbar.Toolbar.lookupComponent,


    Change
    return this.callParent(arguments)
    to
    return this.callParent([c])

    Incidentally, here's a link to the Chrome V8 bug submission, which has a script that can be used to reproduce the issue.
    http://code.google.com/p/v8/issues/detail?id=2390
    Last edited by stahlman; 2 Nov 2012 at 11:32 AM. Reason: added link to Chrome V8 bug submission

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,583
    Vote Rating
    873
      0  

    Default

    This is a dupe of: EXTJSIV-7578

    FYI I already have logged a ticket for this with the Chromium team: http://code.google.com/p/chromium/is...tail?id=157520
    Evan Trimboli
    Twitter - @evantrimboli

  3. #3
    Sencha Premium Member
    Join Date
    Sep 2011
    Posts
    51
    Vote Rating
    2
      0  

    Default

    Yep. That's it. Thanks.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •