peter nitsch.net

peternitsch.net

Serious bug with Alchemy strings

broken string

Amid the discussion caused by my memory allocation problem on the Adobe Alchemy forum (which I summarized in a previous post), it was confirmed by Cod3 Monk3y, Inc. that std::string is broken in Alchemy. Specifically, the copy constructor does not seem to be functioning properly resulting in very unusual behaviour and rendering the class unusable. This is very bad news for developers like myself who have plans on porting C++ libraries over to Flash, and certainly throws a wrench in my hopes of seeing an online version of ASCIIpOrtal.

For those unfamiliar with copy constructors, they're a special constructor used in C++ used to create a new object as a copy of an existing object. They are essential in heavy operations with the class since they are called when an object is created from another object of the same type, when an object is passed by value as a parameter to a function, and when an object is returned from a function. In the case of std::string, its copy constructor definition can be found in /avm2-libc/include/c++/3.4/bits/basic_string.h as follows:

CODE:
  1. basic_string(const basic_string& __str);

Cod3 Monk3y, Inc. wrote and excellent example, which works in standard g++ but fails in Alchemy, that illustrates the bug (below). Following the bug confirmation, he wrote his own string class which forced copies, but uncovered another nasty bug with std::ifstream.

CODE:
  1. string s1;
  2. string s2;
  3.  
  4. s1 = "a";
  5. s2 = s1; // copy constructor
  6. s1 = "b";
  7.  
  8. // use your favorite TRACE function here
  9. TRACE(s1); // expected: "b", actual: "b"
  10. TRACE(s2); // expected: "a", actual: "b", ERROR

It's not exactly shocking that an unsupported alpha research project like Alchemy has bugs. Hell, we all expected them. What I'm concerned about now, is how silent Adobe has fallen. We're nearly a year into the Alchemy announcement, and there is still no public bugbase or patches. Though I doubt Adobe would abandon such a promising and well received project, I'm worried about the speed at which it's progressing. Hopefully I'm just being too pessimistic and need to be more patient. With MAX right around the corner, we could be in for an update shortly (fingers crossed).

Further reading:
BUG: std::string serious problems
BUG: std::ifstream serious problems

Category: Alchemy, Flash

Tagged: , , ,

2 Responses

  1. makc says:

    they said they never going to make a product out of alchemy, so why do you expect them to re-consider?

  2. Peter Nitsch says:

    makc, I don’t expect them to make a “product” out of Alchemy. I don’t think anyone is under that illusion. I do however expect them to communicate on the status of any on-going project that exists in a widely available player release, even if that communication is “hey guys, we’re not doing any more work on this”. What else would be the point of making announcements and facilitating discussion about them? They’d be better served keeping the whole thing secret.

Leave a Reply