Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8942129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:27:08+00:00 2026-06-15T11:27:08+00:00

I have found a case where e.g. 500 letters/digits with whitespace makes PCRE blow

  • 0

I have found a case where e.g. 500 letters/digits with whitespace makes PCRE blow up when using \w in the regex. I have tried boh TPerlRegEx and Delphi XE2 pcre/obj implementations. Same for both.

I then tried calling

pcre_config(PCRE_CONFIG_MATCH_LIMIT, @vSysStrRegex_MatchLimit_Value); 

But setting match limits does not seem to have any effect. The way I am using it is that I call it once for each thread. (Note: Others have set this to get not set such settings)

I really need the regex library to drop out of parsing instead of continuing until it overflows the stack. (It seems next to impossible to recover the thread/program from that.)

How do I prevent stack overflows in this situation? I can’t control the content parsed or the regular expressions. Thus I am specificly looking for ways to avoid PCRE running into stack overflows through a setting or similar.

Solution by editing TPerlRegEx code:

function TPerlRegEx.Match(AStartOffset: Integer = 0): Boolean;
...
if FHints <> nil then // set by "study" call
  begin
    PPCREExtra(FHints)^.flags := PPCREExtra(FHints)^.flags or PCRE_EXTRA_MATCH_LIMIT_RECURSION;
    PPCREExtra(FHints)^.match_limit_recursion := 750 // 1000 too much in tests
  end
;
OffsetCount := pcre_exec(FPattern, FHints, ...)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T11:27:09+00:00Added an answer on June 15, 2026 at 11:27 am

    You’ve cited some PCRE documentation that describes setting the recursion limit at compile time with the --with-match-limit-recursion configuration option. You can exercise that option if you build the PCRE library yourself. If you read elsewhere in that same document, you’ll find a description of the match_limit_recursion field of the pcre_extra block passed to pcre_exec:

    The default value for match_limit_recursion can be set when PCRE is built; the default default is the same value as the default for match_limit. You can override the default by suppling pcre_exec() with a pcre_extra block in which match_limit_recursion is set, and PCRE_EXTRA_MATCH_LIMIT_RECURSION is set in the flags field. If the limit is exceeded, pcre_exec() returns PCRE_ERROR_RECURSIONLIMIT.

    So, set the recursion limit to something lower than the default. The default is evidently even higher than your actual available stack space; if it were lower, then you’d already be getting the PCRE_ERROR_RECURSIONLIMIT error instead of an OS-raised stack-overflow exception.

    How the Delphi-specific wrappers represent this setting, I have no idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn Microsoft MVC 2, and have in that case found
I have found that I have no problem using require to load something like
I seem to have found a weird edge case where it seems that a
I have found several articles mentioning that using UCM Web Forms you can easily
What is the best way people have found to do String to Lower case
How could one convert a string to upper case. The examples I have found
I think I have found an edge case for sizeWithFont:constrainedToSize: where, on a retina
I have found this answer useful: Accent and case insensitive COLLATE equivalent in Oracle
I have found the DTrace intriguing but have personally failed to see a use-case
I have found Okapi Similarity measure can be used to calculated document similarity from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.