diff options
| author | Karl Heuer | 1997-12-04 05:53:41 +0000 |
|---|---|---|
| committer | Karl Heuer | 1997-12-04 05:53:41 +0000 |
| commit | 03effc232ed9b79aba077d912f17dd844d703e5e (patch) | |
| tree | e91246d01037b45473d1afaf55243968ce299463 | |
| parent | d64478da0b0676f77831ca332ccb6a88c4b5e319 (diff) | |
| download | emacs-03effc232ed9b79aba077d912f17dd844d703e5e.tar.gz emacs-03effc232ed9b79aba077d912f17dd844d703e5e.zip | |
(main): Fix the stack-limit code to calculate
the ratio for re_max_failures accurately and leave some extra slack.
| -rw-r--r-- | src/emacs.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/emacs.c b/src/emacs.c index 5a2ac8504c8..7e43d6ad949 100644 --- a/src/emacs.c +++ b/src/emacs.c | |||
| @@ -595,8 +595,14 @@ main (argc, argv, envp) | |||
| 595 | { | 595 | { |
| 596 | long newlim; | 596 | long newlim; |
| 597 | extern int re_max_failures; | 597 | extern int re_max_failures; |
| 598 | /* Approximate the amount regex.c needs, plus some more. */ | 598 | /* Approximate the amount regex.c needs per unit of re_max_failures. */ |
| 599 | newlim = re_max_failures * 2 * 20 * sizeof (char *); | 599 | int ratio = 20 * sizeof (char *); |
| 600 | /* Then add 33% to cover the size of the smaller stacks that regex.c | ||
| 601 | successively allocates and discards, on its way to the maximum. */ | ||
| 602 | ratio += ratio / 3; | ||
| 603 | /* Add in some extra to cover | ||
| 604 | what we're likely to use for other reasons. */ | ||
| 605 | newlim = re_max_failures * ratio + 200000; | ||
| 600 | #ifdef __NetBSD__ | 606 | #ifdef __NetBSD__ |
| 601 | /* NetBSD (at least NetBSD 1.2G and former) has a bug in its | 607 | /* NetBSD (at least NetBSD 1.2G and former) has a bug in its |
| 602 | stack allocation routine for new process that the allocation | 608 | stack allocation routine for new process that the allocation |
| @@ -607,8 +613,8 @@ main (argc, argv, envp) | |||
| 607 | if (newlim > rlim.rlim_max) | 613 | if (newlim > rlim.rlim_max) |
| 608 | { | 614 | { |
| 609 | newlim = rlim.rlim_max; | 615 | newlim = rlim.rlim_max; |
| 610 | /* Don't let regex.c overflow the stack. */ | 616 | /* Don't let regex.c overflow the stack we have. */ |
| 611 | re_max_failures = newlim / (2 * 20 * sizeof (char *)); | 617 | re_max_failures = (newlim - 200000) / ratio; |
| 612 | } | 618 | } |
| 613 | if (rlim.rlim_cur < newlim) | 619 | if (rlim.rlim_cur < newlim) |
| 614 | rlim.rlim_cur = newlim; | 620 | rlim.rlim_cur = newlim; |