bugGnash - The GNU Flash player - Bugs: bug #21788, Array "indexing" problem

 
 

bug #21788: Array "indexing" problem

Submitted by:  Udo Giacomozzi <udog>
Submitted on:  Thu 13 Dec 2007 02:08:57 PM UTC  
 
Category: ActionScriptSeverity: 3 - Normal
Release: NoneStatus: Duplicate
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Tue 29 Jan 2008 10:47:01 PM UTC, comment #6:

This is actually a duplicate of bug #19760.

Sandro Santilli <strk>
Project Member
Wed 19 Dec 2007 03:08:41 AM UTC, comment #5:

--case1---

var foo = [];
foo["3"] = 1;
foo["2"] = 2;
foo["1"] = 3;

after compile(Ming):

push "foo" 0
initArray
setVariable
push "foo"
getVariable
push "3" 1
setMember
push "foo"
getVariable
push "2" 2
setMember
push "foo"
getVariable
push "1" 3
setMember

---case2---
var obj = Object();
obj.x = 1;
obj.y = 2;
obj.z = 3;

after compile(Ming):

push "obj" 0 "Object"
callFunction
setVariable
push "obj"
getVariable
push "x" 1
setMember
push "obj"
getVariable
push "y" 2
setMember
push "obj"
getVariable
push "z" 3
setMember

seems you don't know(in case1) "1" "2" "3" are array indices or normal properties or not.

> string is invalid array index to me at the moment.


sorry, I was wrong.

Zou Lunkai <zoulunkai>
Wed 19 Dec 2007 02:32:34 AM UTC, comment #4:

> Please check the final opcodes and do the deduction later:
> This cann't prove string type variables are valid index!


It is against the disscussion for array index on gnash IRC, not for UdoG's finding.

Zou Lunkai <zoulunkai>
Wed 19 Dec 2007 02:17:17 AM UTC, comment #3:

Please check the final opcodes and do the deduction later:

> var foo = [];
> foo["3"] = 1;
> foo["2"] = 2;
> foo["1"] = 3;


This cann't prove string type variables are valid index! To test array index, you'd better use formal syntax:) eg.
var foo = new Array(0;
foo.push(1);
foo.push(2);

and then check if your index work.

BTW, don't forget to check the final opcodes and string is invalid array index to me at the moment.

Zou Lunkai <zoulunkai>
Thu 13 Dec 2007 02:53:05 PM UTC, comment #2:

Known problem.
See also bug #19760.
The Array class implementation tries to be performant as to elements acces, but we do know by now that doing so pretty much
breaks the semantic of it.

Many of the Array class method should instead work on normal objects, only by means of normal properties..

You're welcome in taking care of this :)

Sandro Santilli <strk>
Project Member
Thu 13 Dec 2007 02:18:13 PM UTC, comment #1:

Re note 3: it's not an endless loop. Instead, the index value seems to affect the array size. Change the index values to 30000,20000,10000 and you'll see what I mean:

foo["30000"] = 1;
foo["20000"] = 2;
foo["10000"] = 3;

leads to this output:

17426] 15:15:56: TRACE: 30001 elements
17426] 15:15:56: TRACE: [30000:number]
17426] 15:15:56: TRACE: [29999:number]
17426] 15:15:56: TRACE: [29998:number]
17426] 15:15:56: TRACE: [29997:number]
17426] 15:15:56: TRACE: [29996:number]
17426] 15:15:56: TRACE: [29995:number]
....

PP agrees with the array size, but processes only three elements:

30001 elements
[10000:string]
[20000:string]
[30000:string]

Compiled SWF attached.

(file #14619)

Udo Giacomozzi <udog>
Project Member
Thu 13 Dec 2007 02:08:57 PM UTC, original submission:

The following function is not executed correctly in Gnash:

function do_test() {
var foo = [];

foo["3"] = 1;
foo["2"] = 2;
foo["1"] = 3;

trace(foo.length+" elements");

for (var bar in foo) {
foo[bar] *= _root.something;
trace("["+bar+":"+(typeof bar)+"]");
}
}

do_test();

output with proprietary player

4 elements
[1:string]
[2:string]
[3:string]

output with Gnash

17325] 15:04:11: TRACE: 4 elements
17325] 15:04:11: TRACE: [3:number]
17325] 15:04:11: TRACE: [2:number]
17325] 15:04:11: TRACE: [1:number]
17325] 15:04:11: TRACE: [0:number]

Problem 1: Gnash says the variable is a "number", it should be "string"

Problem 2: Gnash finds four elements in an array that has only three, even though also PP says it contains 4 elements !?

Problem 3: The order is wrong

Note 1: It does not matter that the code is inside a function (checked)

Note 2: I still get four trace()s with Gnash when I use numeric indexes.

Note 3: I wanted to create a testcase for a different problem where a much similar code (especially the for loop) becomes an endless loop

Note 4: the assignment to foo[bar] inside the "for" section can be removed -> still same problem

Udo Giacomozzi <udog>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #14619:  foreach_test.swf added by udog (233B - application/x-shockwave-flash)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by zoulunkai (Posted a comment)
  • -unavailable- added by strk (Posted a comment)
  • -unavailable- added by strk (for having been the last major contributor to the class)
  • -unavailable- added by udog (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 29 Jan 2008 10:47:01 PM UTCstrkStatusNone=>Duplicate
      Open/ClosedOpen=>Closed
    Thu 13 Dec 2007 02:53:05 PM UTCstrkCarbon-Copy-=>Added meteoryte
    Thu 13 Dec 2007 02:18:13 PM UTCudogAttached File-=>Added foreach_test.swf, #14619

    Back to the top


    Powered by Savane 3.1-cleanup1