Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2015-09-21
17:29
[a3c3508599] Fix typo that reversed test sense in prior fix for [3610026]. closed check-in: 3a17aa1449 user: dgp tags: tgl-pg-re
2013-04-09
03:07 • Closed ticket [3610026fff]: A regular expression with > 32k "colors&quot... artifact: 6656611058 user: dgp
02:45 • Ticket [3610026fff]: 5 changes artifact: 1bc9a01ccd user: dgp
01:59 • Ticket [3610026fff]: 4 changes artifact: 62e6c0ff76 user: dkf
01:59 • Ticket [3610026fff]: 4 changes artifact: 4dd8cb4623 user: dkf
2013-04-08
22:17 • Ticket [3610026fff]: 4 changes artifact: f22472ef0e user: dgp
22:17 • Ticket [3610026fff]: 1 change artifact: 0f0effcccb user: dgp
22:17 • Ticket [3610026fff]: 4 changes artifact: 5306e8af96 user: dgp
2013-04-05
03:24 • Ticket [3610026fff]: 4 changes artifact: 45c187447d user: dgp
00:27 • Ticket [3610026fff]: 5 changes artifact: fb3ba8646a user: dgp
00:21 • Ticket [3610026fff]: 5 changes artifact: 01e5398d2f user: dgp
2013-04-04
23:50 • Add attachment tclcrash.tcl to ticket [3610026fff] artifact: e93b13e873 user: hlinnaka
23:50 • Ticket [3610026fff] A regular expression with > 32k "colors" causes... artifact: f25322e797 user: hlinnaka
16:50 • New ticket [3610026fff]. artifact: 5390095040 user: hlinnaka

A regular expression with > 32k "colors" causes a segfault

Closed / Fixed3610026fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 14 years ago
Descriptionplain2013-04-04 16:50:39
If a regular expression is parsed into more than 32k colors, you get a crash. I initially spotted this in PostgreSQL (http://www.postgresql.org/message-id/[email protected]), but TCL shares the same code and thus has the same bug. 

Attached is a TCL test script to reproduce this.

Here's a link to the PostgreSQL commit that fixed this: http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=bf2b0a147857f63daa2e5c17eed0169861371af8. It should apply to TCL sources with minimal changes.
hlinnakaplain2013-04-04 23:50:40
File Added - 462305: tclcrash.tcl
dgpplain2013-04-05 00:21:07
What encoding is that demo file in ?  It appears
mangled.
dgpplain2013-04-05 00:27:08
It appears the segfault is avoided in Tcl 8.6,
probably due to the DUP_TRAVERSE_MAX_DEPTH
limits imposed there.

I see the segfault in Tcl 8.5. though.

A tidier demo convertible to a test case
would be welcome.  I will get to it eventually.
dgpplain2013-04-05 03:24:31
Simpler demo:

set e {}
set cp 99
while {$cp < 35000} {
append e [format %c [incr cp]]
}
regexp -about $e
dgpplain2013-04-08 22:17:31
Branch bug-3610026 contains the test and the (slightly
adapted) patch.

It's good to stop the crash.  The only significant problem
with this patch is that the test requires 10s of seconds to run,
at least on my machine.  I'd like opinions on whether we
should constrain it to not run on every make test for that
reason.
dgp Ticket [3610026fff]: 1 change [History diff]2013-04-08 22:17:32
dgpplain2013-04-08 22:17:41
Branch bug-3610026 contains the test and the (slightly
adapted) patch.

It's good to stop the crash.  The only significant problem
with this patch is that the test requires 10s of seconds to run,
at least on my machine.  I'd like opinions on whether we
should constrain it to not run on every make test for that
reason.
dkfplain2013-04-09 01:59:46
It takes 5-6 seconds on this rather elderly machine, which is acceptable. (Your system must be even older, and this machine's now old enough to be of school age!)

I don't think the test is looking for the right result though. Either it's looking for a non-crash (in which case we ought to allow for success) or it should look for the specific new error message. I'm cool either way, but the current "gimme an error, any error" feels uncomfortable given that the rest of the file does lots of testing for specific errors.
dkfplain2013-04-09 01:59:56
IP - Comment Removed: 82.42.214.208
dgpplain2013-04-09 02:45:58
Fix committed for Tcl 8.4.20.
dgpplain2013-04-09 03:07:12
allow_comments - 1

and 8.5.15 and 8.6.1.
Log in (anonymous is fine) to add a comment.

Attachments: