[Crash-utility] [PATCH] Fix memory leaks in dump_mem_map when SPARSEMEM is enabled

Dave Anderson anderson at redhat.com
Tue Jun 16 16:32:29 UTC 2015



----- Original Message -----
> > Date: Tue, 16 Jun 2015 11:14:51 -0400
> > From: anderson at redhat.com
> > To: crash-utility at redhat.com
> > Subject: Re: [Crash-utility] [PATCH] Fix memory leaks in dump_mem_map when
> > SPARSEMEM is enabled
> > 
> > 
> > Hi Oliver,
> > 
> > Since it's a GETBUF() call, it's not really a memory leak (by design).
> 
> Dave,
> 
> Sorry, I'm not familiar the code.
> 
> If the dump_mem_map get called in a thousand loop, the crash could reported
> memory allocation errors and exit the loop.

Yes, except for the fact that dump_mem_map() is never called in a loop.
But since your proposed patch does that, then yes, it would be a problem.

Dave


> After I fixed with this patch, the issue got disappeared.
>
> I'm not sure you know the reason, if not, I can show you the error messages.
> 
> > But it's certainly unnecessary for CONFIG_SPARSEMEM kernels. Queued
> > for crash-7.1.2:
> > 
> > https://github.com/crash-utility/crash/commit/005eb9e502056a09196f6507162648c796e36f95
> > 
> > Thanks,
> > Dave
> > 
> > 
> > ----- Original Message -----
> > > Signed-off-by: Yong Yang <yangoliver at gmail.com>
> > > ---
> > > memory.c | 7 +++----
> > > 1 file changed, 3 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/memory.c b/memory.c
> > > index 32427ea..765732b 100644
> > > --- a/memory.c
> > > +++ b/memory.c
> > > @@ -5734,10 +5734,6 @@ dump_mem_map(struct meminfo *mi)
> > > long buffersize;
> > > char *outputbuffer;
> > > int bufferindex;
> > > -
> > > - buffersize = 1024 * 1024;
> > > - outputbuffer = GETBUF(buffersize + 512);
> > > -
> > > char style1[100];
> > > char style2[100];
> > > char style3[100];
> > > @@ -5748,6 +5744,9 @@ dump_mem_map(struct meminfo *mi)
> > > return;
> > > }
> > > 
> > > + buffersize = 1024 * 1024;
> > > + outputbuffer = GETBUF(buffersize + 512);
> > > +
> > > sprintf((char *)&style1, "%%lx%s%%%dllx%s%%%dlx%s%%8lx %%2d%s",
> > > space(MINSPACE),
> > > (int)MAX(PADDR_PRLEN, strlen("PHYSICAL")),
> > > --
> > > 1.9.1
> > > 
> > > --
> > > Crash-utility mailing list
> > > Crash-utility at redhat.com
> > > https://www.redhat.com/mailman/listinfo/crash-utility
> > > 
> > 
> > --
> > Crash-utility mailing list
> > Crash-utility at redhat.com
> > https://www.redhat.com/mailman/listinfo/crash-utility
> 
> --
> Crash-utility mailing list
> Crash-utility at redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility




More information about the Crash-utility mailing list