Status: New
Owner: ----

New issue 778 by [email protected]: RegExp's not correctly executing if called multiple times (loop).
http://code.google.com/p/v8/issues/detail?id=778

This issue is really hard to reproduce, I have spend countless hours trying to create a smaller use case but I'm unable to do so..

The issue:

When you have a regular expression that gets executed multiple times after you have created it, the results that the regular expression produces will be different. Sometimes even producing different results on the same string.

This only happens if you construct a regular expression like this:

server_split_re = /(.*):(\d+){1,}$/;

If you compile a regexp your self, V8 will run as expected:

server_split_re = new RegExp( "(.*):(\\d+){1,}$" );

Example scripts:
I have had 2 different scripts that can reproduce this issue. One browser based script and one script that runs on node.js.

Tokenizing example:

https://gist.github.com/420783/4376b2d326b25cb8e72a2a576fde12d6baca7fbd
In the script above the tknRegExp will be executed multiple times 1x outside the loop, creating the initial match for the while loop and at the bottom of the while loop so we can increase the token match.

The tokenizing will fail to execute properly in Google Chrome and gives a false result set. When we are using new RegExp to construct the regexp, there are no issues. ( https://gist.github.com/420783/9b2e2dc5a057831fc5a45a043b0e0541f19b76f1 )

Memcached server splitting:
http://github.com/3rd-Eden/node-memcached/blob/ed31d571cdf30b29c49e69d6d0f9f1994da36172/memcached.js

In the example above you will see a first part of my memcached client for node.js with consistent hashing support. In the connect() method the server's are getting split so we have the host name and port number.

V8, will be unable to chunk all servers properly if the memcached client is constructed with multiple servers: https://gist.github.com/95bdb483ad8d08a283bf

Again, if we change the /regexp/ to a new RegExp(regexp) there will be no issues:

http://github.com/3rd-Eden/node-memcached/blob/91f296ea32708800867b3efcf72f5f3ffef3e195/memcached.js

Hopes this helps


--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to