Log On
Embarcadero Home
Watch, Follow, &
Connect with Us
Share This
QualityCentral
Communities
Articles
Blogs
Resources
Downloads
Help
QualityCentral
Delphi-BCB
RTL
Delphi
Arithmetic
ConvUtils
Date - Time
DateUtils
File Management
Format + Float
Input/Output
Math Unit
Memory, Pointer, Address
Null-terminated strings
Other Classes
Other RTL
Pascal Strings
Regular Expressions
RTL Exceptions
Text Files
Thread support
Typed/Untyped Files
WinAPI
You are not logged in.
Help
Print
Public Report
Report From:
Delphi-BCB/RTL/Delphi/Regular Expressions
[ Add a report in this area ]
Report #:
87752
Status:
Closed
TRegEx frees FRegEx while TMatch et al still have a reference to it
Project:
Delphi
Build #:
15.0.3890.34076
Version:
15.0
Submitted By:
Jan Goyvaerts
Report Type:
Crash / Data loss / Total failure
Date Reported:
9/2/2010 7:57:11 PM
Severity:
Critical / Show Stopper
Last Updated:
3/20/2012 2:24:39 AM
Platform:
All platforms
Internal Tracking #:
280323
Resolution:
Fixed
(Resolution Comments)
Resolved in Build:
:
16.0.4115.38113
Duplicate of:
None
Voting and Rating
Overall Rating:
No Ratings Yet
0.00 out of 5
Total Votes:
11
Description
The TRegEx record allocates a TPerlRegEx instance that it stores in the FRegEx field. It uses TScopeExitNotifier to free the TPerlRegEx instance when the TRegEx record goes out of scope. It's a nifty trick, but it fails spectacularly because TMatch and TGroupCollection copy the reference to the TPerlRegEx instance but not the TScopeExitNotifier.
An FNotifier field must be added to TMatch and TGroupCollection. TRegEx.FNotifier must be assigned to TMatch.FNotifier and TGroupCollection.FNotifier whenever TRegEx.FRegEx is assigned to TMatch.FRegEx and TGroupCollection.FRegEx.
Steps to Reproduce:
1. Start a new VCL application
2. Turn on debug DCUs in project options
3. Add RegularExpressions to the uses clause of Unit1
4. Add a TButton with this event handler:
procedure TForm1.Button1Click(Sender: TObject);
begin
Button1.Caption := TRegEx.Match('one two', '\w+').NextMatch.Value;
end;
5. Open the RegularExpressionsCore unit
6. Place breakpoints in TPerlRegEx.Create, TPerlRegEx.Destroy, and TPerlRegEx.MatchAgain
7. Run the application
Expected: breakpoints stop at Create, MatchAgain, and Destroy in that order, and the button's caption shows "two".
Actual: breakpoints stop at Create, Destroy, and MatchAgain in that order, showing that MatchAgain is called on a TPerlRegEx instance that has already been destroyed. In my tests the button caption goes blank, but in real world code the program may very well crash with an access violation.
Workarounds
None
Attachment
None
Comments
Olaf Hess at 11/14/2010 10:02:59 AM
-
See
http://www.regexguru.com/2010/09/bug-in-delphi-xe-regularexpressions-unit/
for more info and how to fix.
Does not seem to be fixed in "Update 1 for Delphi XE".
Tomohiro Takahashi at 11/14/2010 4:54:05 PM
-
Thanks for the information. I forward it to internal tracking system.
Jan Goyvaerts at 12/17/2010 7:02:06 PM
-
Since the fix requires an interface change, I'm sure this won't be fixed in a Delphi XE update.
Tomohiro Takahashi at 4/24/2011 6:05:16 PM
-
Is your issue same as QC#90036?
Please take a look at the [Workaround] .
View Your Reports
Search
Server Response from: ETNACODE01
Developer Tools
Blackfish SQL
C++Builder
Delphi
FireMonkey
Prism
InterBase
JBuilder
J Optimizer
HTML5 Builder
3rdRail & TurboRuby
Database Tools
Change Manager
DBArtisan
DB Optimizer
ER/Studio
Performance Center
Rapid SQL
Technical Articles
Tutorials
White Papers
Press Releases
Newsletters
Add Content (GetPublished)
Audio
Audio & Video
Video
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Tags
Technology Partners
Downloads
Free Trials
Registered User Downloads
Beta Programs
Add Content (GetPublished)
Articles
Blogs
Bugs & Suggestions (QualityCentral)
Discussion Forums
Examples (CodeCentral)
Member Services
About
Connect with Us