bugGnash - The GNU Flash player - Bugs: bug #24117, Cannot convert number to string

 
 

bug #24117: Cannot convert number to string

Submitted by:  Nico Coesel <ncoesel>
Submitted on:  Fri 22 Aug 2008 08:20:22 AM UTC  
 
Category: ActionScriptSeverity: 3 - Normal
Release: 0.8.3 releaseStatus: Wont Fix
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)

Mon 25 Aug 2008 12:41:09 PM UTC, comment #9:

Cool. Closing the bug report.

Benjamin Wolsey <bwy>
Project Member
Mon 25 Aug 2008 12:36:12 PM UTC, comment #8:

I managed to fix the problem. As I already stated the problem is not in Gnash, it is in the underlying uclibc stdc++ libraries (See issue 0001090 on busybox.net).

Nico Coesel <ncoesel>
Fri 22 Aug 2008 01:37:30 PM UTC, comment #7:

Right. The locale::imbue() function is used because otherwise the number is represented with the decimal separator of the current locale: for many of us, of course, a comma rather than the dot required by ActionScript.

I had already changed the locale constructor to use std::locale::classic() rather than std::locale("C") while looking at that code a couple of days ago, and that's now committed. I doubt it will help your case at all, but if it's that flaky you never know.

Benjamin Wolsey <bwy>
Project Member
Fri 22 Aug 2008 01:27:30 PM UTC, comment #6:

I've tried both snprintf and boost::format inside doubletoString. I investigated a bit further and it seems stdlibc++ uses locales to convert numbers to strings. If I fiddle a bit with the line ostr.imbue(std::locale("C")) (changing "C" into other locales) I get various results ranging from segmentation faults, garbled output to exceptions in stdlibc++.

Bottom line: the problem is not in Gnash the problem is in stdlibc++ combined with locales.

Nico Coesel <ncoesel>
Fri 22 Aug 2008 10:22:20 AM UTC, comment #5:

Where are you using snprintf or boost::format? Inside doubleToString?

Benjamin Wolsey <bwy>
Project Member
Fri 22 Aug 2008 10:04:32 AM UTC, comment #4:

I tried the boost::format function in the mean time, but this results in total garbage of the entire output string. Therefore I tried to use the good old snprintf which appears to work okay. So the problem is inside the doubletoString function.

Nico Coesel <ncoesel>
Fri 22 Aug 2008 09:33:32 AM UTC, comment #3:

So if the character is different every time, it looks like it's garbage data.

In your case (val = a small integer), the process in doubleToString should just be:

std::ostringstream o;

o << setprecision(15) << val;

std::string str = o.str();

return str;

Even if the ostream operation fails, str should be a valid (empty) string.

Benjamin Wolsey <bwy>
Project Member
Fri 22 Aug 2008 09:09:21 AM UTC, comment #2:

Benjamin,
I tried your swf. Here is the output:
434:1024] 02:09:40 TRACE: a 0 c.length 0 cvalue e:0
434:1024] 02:09:40 TRACE: a Ð c.length Ð cvalue a e:
434:1024] 02:09:40 TRACE: a Ð c.length Ð cvalue aa e:
434:1024] 02:09:40 TRACE: a Ð c.length Ð cvalue aaa e:
434:1024] 02:09:40 TRACE: a Ð c.length Ð cvalue aaaa e:

I'm looking at the doubletoString function in as_value.cpp. As 0 gets printed properly there may be something wrong in the iostringstream implementation. I'll give the boost format function a try and see what happens then.

Nico Coesel <ncoesel>
Fri 22 Aug 2008 08:57:33 AM UTC, comment #1:

This works fine for me.

I assume you are using the same swf for both Gnash and the PP; can you (a) try the SWF I've attached (it's your code compiled with ming) and confirm whether it has the same bug in Gnash, and (b) attach the SWF that's failing for you.

I'd expect that both of them display the same behaviour for you (and work for me) suggesting that it's a Gnash bug on MIPS.

Do you have any idea what Ø might be? Testing with current head would also be helpful.

Meanwhile, I'll look at the as_value code.

(file #16332)

Benjamin Wolsey <bwy>
Project Member
Fri 22 Aug 2008 08:20:22 AM UTC, original submission:

There is something wrong when I try to convert a number to a string. I have the following action script code:

var c:String = "";
var d:String = "";
var e:String = "";
c="";

for (var a = 0; a<5; a++) {
e=String(a);
d="a " + a +" c.length " +c.length +" cvalue "+ c + " e:" +e;
trace(d);
c += "a";
}

With Adobe Flash CS3 this gives the following output:
a 0 c.length 0 cvalue e:0
a 1 c.length 1 cvalue a e:1
a 2 c.length 2 cvalue aa e:2
a 3 c.length 3 cvalue aaa e:3
a 4 c.length 4 cvalue aaaa e:4

Gnash produces the following output:
421:1024] 01:19:49 TRACE: a 0 c.length 0 cvalue e:0
421:1024] 01:19:49 TRACE: a p c.length p cvalue a e:Ø
421:1024] 01:19:49 TRACE: a p c.length p cvalue aa e:Ø
421:1024] 01:19:49 TRACE: a p c.length p cvalue aaa e:Ø
421:1024] 01:19:49 TRACE: a p c.length p cvalue aaaa e:Ø

I'm using a MIPS platform. Both big and little endian give the same results.

Nico Coesel <ncoesel>

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #16332:  tostr.swf added by bwy (194B - application/x-shockwave-flash - Version working (for bwy))

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bwy (Updated the item)
  • -unavailable- added by ncoesel (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 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 25 Aug 2008 12:41:09 PM UTCbwyStatusNone=>Wont Fix
      Open/ClosedOpen=>Closed
    Fri 22 Aug 2008 08:57:33 AM UTCbwyAttached File-=>Added tostr.swf, #16332

    Back to the top


    Powered by Savane 3.1-cleanup1