https://bugzilla.novell.com/show_bug.cgi?id=366441
Summary: Regex class is not threadsafe
Product: Mono: Class Libraries
Version: SVN
Platform: i686
OS/Version: All
Status: NEW
Severity: Major
Priority: P5 - None
Component: System
AssignedTo: [email protected]
ReportedBy: [EMAIL PROTECTED]
QAContact: [email protected]
Found By: Field Engineer
The Regex class, after construction should be threadsafe as the state machine
should be readonly after construction. For some reason, the Regex class is not
threadsafe. A temporary fix is to protect the instance methods of the Regex
class such as Regex.Match with a lock but this is not ideal.
The following program is a test case:
using System;
using System.Threading;
using System.Text.RegularExpressions;
public class Test
{
protected static Regex c_Regex = new Regex
(
@"(ANS_TIME_POSITION\=)([0-9\.]+)", RegexOptions.IgnoreCase
);
private static void Run()
{
string s;
Match match;
s = "ANS_TIME_POSITION=100.0";
while (true)
{
match = c_Regex.Match(s);
if (!match.Success)
{
Console.WriteLine("ERROR 1");
}
if (match.Groups[2].Value != "100.0")
{
Console.WriteLine("ERROR 2");
}
}
}
public static void Main()
{
Thread thread1, thread2;
thread1 = new Thread(Run);
thread1.Start();
thread2 = new Thread(Run);
thread2.Start();
}
}
--
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs