Welcome! Log In Create A New Profile

Advanced

Re: Re: Re: fix accidental corrdump

Frank Swasey
September 29, 2022 04:38PM
This is getting quite tiresome. You are both stuck in your point of view
and refusing to hear what the other one is saying.

Maxim - you keep repeating " l->alloc is not used after free(). " Clearly,
that is not true if setting it to NULL prevents the segfault. What is true
is that NGINX core code does not use it. As a defensive coding technique,
I agree with zjd that setting the pointer you just freed to NULL to
indicate to any other code that is checking it is the proper action. The
only other thing that zjd can do is to set the pointer to NULL in their own
code after calling the reset function if you are adamant that such
defensive measures cannot be put into the NGINX core code. Any future
programmers that write modules like zjd has done that test a pointer for
being NULL and use it if it has a non-NULL value, will trip over the same
problem, and you can have this argument all over again.

~ Frank Swasey, lurker

On Thu, Sep 29, 2022 at 3:53 PM Maxim Dounin <mdounin@mdounin.ru> wrote:

> Hello!
>
> On Thu, Sep 29, 2022 at 04:30:45PM +0800, zjd wrote:
>
> > Actually, I'm not sure where is coredump; So I think
> > l->alloc=NULL after free(l-alloc) is reasonable, because
> > l->alloc's address can be reused in the pool. Of course,
> > memzero after get mem from the pool can be solved about this
> > question.But for example, ngx_array_push maybe reuse l->alloc's
> > address, and ngx_array_push is not memzero from the start of
> > get memory.
> > So I think l->alloc=NULL after free(l-alloc) is necessary.
> > Thanks for discussing this with me
>
> As previously explained, l->alloc is not used after free().
> Clearing unused memory without reasons is certainly not necessary,
> much like clearing allocated memory. While it might be helpful to
> mitigate various bugs, a better approach would be to find and fix
> bugs.
>
> To find and fix bugs a better approach is usually to set the
> unused memory to a pattern which is more likely to cause segfault
> if used, such as memset(0x5A). In nginx, various mechanisms to
> facilitate memory debugging are available with NGX_DEBUG_MALLOC
> and NGX_DEBUG_PALLOC defines, see code for details. Using system
> allocator options, Address Sanitizer, and tools like Valgrind also
> might be helpful.
>
> --
> Maxim Dounin
> http://mdounin.ru/
> _______________________________________________
> nginx mailing list -- nginx@nginx.org
> To unsubscribe send an email to nginx-leave@nginx.org
>


--
I am not young enough to know everything. - Oscar Wilde (1854-1900)
_______________________________________________
nginx mailing list -- nginx@nginx.org
To unsubscribe send an email to nginx-leave@nginx.org
Subject Author Posted

fix accidental corrdump

zjd September 27, 2022 03:26AM

Re: fix accidental corrdump

Maxim Dounin September 27, 2022 04:54PM

Re:Re: fix accidental corrdump

zjd September 27, 2022 10:58PM

Re: Re: fix accidental corrdump

Maxim Dounin September 28, 2022 11:58AM

Re:Re: Re: fix accidental corrdump

zjd September 29, 2022 04:32AM

Re: Re: Re: fix accidental corrdump

Maxim Dounin September 29, 2022 03:54PM

Re: Re: Re: fix accidental corrdump

Frank Swasey September 29, 2022 04:38PM

Re: Re: Re: fix accidental corrdump

Maxim Dounin September 29, 2022 07:22PM

Re:Re: Re: Re: fix accidental corrdump

zjd September 30, 2022 12:10AM

Re: Re: Re: Re: fix accidental corrdump

Maxim Dounin September 30, 2022 08:08AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 90
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready