[erlang-bugs] Re bug

PAILLEAU Eric <>
Sat Mar 3 17:27:03 CET 2012


Le 03/03/2012 16:42, Robert Virding a écrit :
> Hi Eric,
> 
> Yes, I know I can shorten it. The bug, as I see it, is that it suddenly gives up and returns 'nomatch' on a pattern/string which should match. Now I will admit that this is a very pathological pattern and that the time taken to match grows exponentially (I think) and if you give n=30 you will have to wait a long time. But if it gives up it should tell me that, perhaps return an error or crash, not lie.
> 
> Hadn't noticed the 69, but of course 23+46=69 :-)

Hi Robert,

the strange thing :

6>re:run(string:copies("a",23),string:copies("a?",23)++string:copies("a",23)).
nomatch

while :

7>re:run(string:copies("a",24),string:copies("a?",23)++string:copies("a",23)).
{match,[{0,24}]}

the pattern that do not mach with 23, does on a 24 length string and not
on the 23 length string.
So the length of the pattern is may be not the reason but the fact
that the string is modulo the pattern... but why after 23 ... mystery .
It looks like it is a real bug in such case...

Note that the shorten notation is not only shorter but much more quick
than yours (*I know your way is just for fun*)

re:run(string:copies("a",30), "a{0,30}a{30}").  returns immediately,

as well re:run(string:copies("a",1000), "a{0,1000}a{1000}") !!!

while
re:run(string:copies("a",1000),string:copies("a?",1000)++string:copies("a",1000))
take almost 5 seconds to return on my laptop.

Best regards.


More information about the erlang-bugs mailing list