Re: [PATCH] die routine: change recursion limit from 1 to 1024
- From
Simon Ruderich <simon@ruderich.org>
- Date
- Jun 21, 2017, 08:12 UTC
- Message-ID
- <20170621081209.gfqqkselek4bqdjl@ruderich.org>
- In-Reply-To
- <87lgom8pew.fsf@gmail.com>
On Tue, Jun 20, 2017 at 08:49:59PM +0200, Ævar Arnfjörð Bjarmason wrote:
Show 14 quoted lines
> If I understand you correctly this on top:
>
> diff --git a/usage.c b/usage.c
> index 1c198d4882..f6d5af2bb4 100644
> --- a/usage.c
> +++ b/usage.c
> @@ -46,7 +46,19 @@ static int die_is_recursing_builtin(void)
> static int dying;
> static int recursion_limit = 1024;
>
> - return dying++ > recursion_limit;
> + dying++;
> +
> + if (!dying) {This will never trigger as dying was incremented two lines before. But I think it's already handled by the dying < recursion_limit case so we can just omit it.
Show 11 quoted lines
> + /* ok, normal */
> + return 0;
> + } else if (dying < recursion_limit) {
> + /* only show the warning once */
> + if (dying == 1)
> + warning("die() called many times. Recursion error or racy threaded death!");
> + return 0; /* don't bail yet */
> + } else {
> + return 1;
> + }
> }Maybe restructure it like this:
dying++
if (dying > recursion_limit)
return 1;
if (dying == 1)
warning();
return 0;Btw. is there a reason why recursion_limit is a static variable and not a constant/define?
Regards Simon
-- + privacy is necessary + using gnupg http://gnupg.org + public key id: 0x92FEFDB7E44C32F9