mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-08-13 01:26:58 +00:00
update to pcre 7.9
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13706 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -52,7 +52,7 @@ frame for each matched character. For a long string, a lot of stack is
|
||||
required. Consider now this rewritten pattern, which matches exactly the same
|
||||
strings:
|
||||
.sp
|
||||
([^<]++|<(?!inet))
|
||||
([^<]++|<(?!inet))+
|
||||
.sp
|
||||
This uses very much less stack, because runs of characters that do not contain
|
||||
"<" are "swallowed" in one item inside the parentheses. Recursion happens only
|
||||
@@ -61,6 +61,13 @@ assume this is relatively rare). A possessive quantifier is used to stop any
|
||||
backtracking into the runs of non-"<" characters, but that is not related to
|
||||
stack usage.
|
||||
.P
|
||||
This example shows that one way of avoiding stack problems when matching long
|
||||
subject strings is to write repeated parenthesized subpatterns to match more
|
||||
than one character whenever possible.
|
||||
.
|
||||
.SS "Compiling PCRE to use heap instead of stack"
|
||||
.rs
|
||||
.sp
|
||||
In environments where stack memory is constrained, you might want to compile
|
||||
PCRE to use heap memory instead of stack for remembering back-up points. This
|
||||
makes it run a lot more slowly, however. Details of how to do this are given in
|
||||
@@ -68,27 +75,17 @@ the
|
||||
.\" HREF
|
||||
\fBpcrebuild\fP
|
||||
.\"
|
||||
documentation.
|
||||
.P
|
||||
In Unix-like environments, there is not often a problem with the stack, though
|
||||
the default limit on stack size varies from system to system. Values from 8Mb
|
||||
to 64Mb are common. You can find your default limit by running the command:
|
||||
documentation. When built in this way, instead of using the stack, PCRE obtains
|
||||
and frees memory by calling the functions that are pointed to by the
|
||||
\fBpcre_stack_malloc\fP and \fBpcre_stack_free\fP variables. By default, these
|
||||
point to \fBmalloc()\fP and \fBfree()\fP, but you can replace the pointers to
|
||||
cause PCRE to use your own functions. Since the block sizes are always the
|
||||
same, and are always freed in reverse order, it may be possible to implement
|
||||
customized memory handlers that are more efficient than the standard functions.
|
||||
.
|
||||
.SS "Limiting PCRE's stack usage"
|
||||
.rs
|
||||
.sp
|
||||
ulimit -s
|
||||
.sp
|
||||
The effect of running out of stack is often SIGSEGV, though sometimes an error
|
||||
message is given. You can normally increase the limit on stack size by code
|
||||
such as this:
|
||||
.sp
|
||||
struct rlimit rlim;
|
||||
getrlimit(RLIMIT_STACK, &rlim);
|
||||
rlim.rlim_cur = 100*1024*1024;
|
||||
setrlimit(RLIMIT_STACK, &rlim);
|
||||
.sp
|
||||
This reads the current limits (soft and hard) using \fBgetrlimit()\fP, then
|
||||
attempts to increase the soft limit to 100Mb using \fBsetrlimit()\fP. You must
|
||||
do this before calling \fBpcre_exec()\fP.
|
||||
.P
|
||||
PCRE has an internal counter that can be used to limit the depth of recursion,
|
||||
and thus cause \fBpcre_exec()\fP to give an error code before it runs out of
|
||||
stack. By default, the limit is very large, and unlikely ever to operate. It
|
||||
@@ -107,9 +104,57 @@ As a very rough rule of thumb, you should reckon on about 500 bytes per
|
||||
recursion. Thus, if you want to limit your stack usage to 8Mb, you
|
||||
should set the limit at 16000 recursions. A 64Mb stack, on the other hand, can
|
||||
support around 128000 recursions. The \fBpcretest\fP test program has a command
|
||||
line option (\fB-S\fP) that can be used to increase its stack.
|
||||
.P
|
||||
.in 0
|
||||
Last updated: 29 June 2006
|
||||
.br
|
||||
Copyright (c) 1997-2006 University of Cambridge.
|
||||
line option (\fB-S\fP) that can be used to increase the size of its stack.
|
||||
.
|
||||
.SS "Changing stack size in Unix-like systems"
|
||||
.rs
|
||||
.sp
|
||||
In Unix-like environments, there is not often a problem with the stack unless
|
||||
very long strings are involved, though the default limit on stack size varies
|
||||
from system to system. Values from 8Mb to 64Mb are common. You can find your
|
||||
default limit by running the command:
|
||||
.sp
|
||||
ulimit -s
|
||||
.sp
|
||||
Unfortunately, the effect of running out of stack is often SIGSEGV, though
|
||||
sometimes a more explicit error message is given. You can normally increase the
|
||||
limit on stack size by code such as this:
|
||||
.sp
|
||||
struct rlimit rlim;
|
||||
getrlimit(RLIMIT_STACK, &rlim);
|
||||
rlim.rlim_cur = 100*1024*1024;
|
||||
setrlimit(RLIMIT_STACK, &rlim);
|
||||
.sp
|
||||
This reads the current limits (soft and hard) using \fBgetrlimit()\fP, then
|
||||
attempts to increase the soft limit to 100Mb using \fBsetrlimit()\fP. You must
|
||||
do this before calling \fBpcre_exec()\fP.
|
||||
.
|
||||
.SS "Changing stack size in Mac OS X"
|
||||
.rs
|
||||
.sp
|
||||
Using \fBsetrlimit()\fP, as described above, should also work on Mac OS X. It
|
||||
is also possible to set a stack size when linking a program. There is a
|
||||
discussion about stack sizes in Mac OS X at this web site:
|
||||
.\" HTML <a href="http://developer.apple.com/qa/qa2005/qa1419.html">
|
||||
.\" </a>
|
||||
http://developer.apple.com/qa/qa2005/qa1419.html.
|
||||
.\"
|
||||
.
|
||||
.
|
||||
.SH AUTHOR
|
||||
.rs
|
||||
.sp
|
||||
.nf
|
||||
Philip Hazel
|
||||
University Computing Service
|
||||
Cambridge CB2 3QH, England.
|
||||
.fi
|
||||
.
|
||||
.
|
||||
.SH REVISION
|
||||
.rs
|
||||
.sp
|
||||
.nf
|
||||
Last updated: 09 July 2008
|
||||
Copyright (c) 1997-2008 University of Cambridge.
|
||||
.fi
|
||||
|
Reference in New Issue
Block a user