Thanks Dave and Ben for your kind replies.

Ben, the Address Sanitizer integration sounds very interesting, if you
could share your WIP patches that would be great!

Best regards,
Elias


On Mon, 2019-09-09 at 12:57 +0000, Benoit Ganne (bganne) via
Lists.Fd.Io wrote:
> Hi Elias,
> 
> As mentioned by Dave, running Valgrind on VPP is challenging because
> of speed and custom allocators.
> That being said, I am (slowly) working on integrating Address
> Sanitizer into VPP. I have some cleanup to do but I can share my WIP
> patches if interested.
> 
> Best
> ben
> 
> > -----Original Message-----
> > From: vpp-dev@lists.fd.io <vpp-dev@lists.fd.io> On Behalf Of Dave
> > Barach
> > via Lists.Fd.Io
> > Sent: lundi 9 septembre 2019 14:20
> > To: Elias Rudberg <elias.rudb...@bahnhof.net>; vpp-dev@lists.fd.io
> > Cc: vpp-dev@lists.fd.io
> > Subject: Re: [vpp-dev] How to use valgrind to check for memory
> > errors in
> > vpp?
> > 
> > Dlmalloc [aka "Doug Lea Malloc"] is a lightly modified copy of the
> > allocator described here: 
> > http://gee.cs.oswego.edu/dl/html/malloc.html. If
> > you've managed to find an issue in it, please share the details.
> > Until
> > proven otherwise, I suspect the report rather than dlmalloc itself.
> > 
> > Vpp does indeed manage its own thread stacks. The so-called vpp
> > process
> > model [in truth: cooperative multi-tasking threads] uses
> > setjmp/longjmp to
> > switch stacks. The scheme is fundamental, and won't be changed to
> > accomodate valgrind.
> > 
> > Dlmalloc does not support valgrind. It's a waste of a huge number
> > of
> > cycles to run valgrind unless the memory allocator supports it. My
> > experience making vpp's previous memory allocator support valgrind
> > might
> > be worth sharing: it never worked very well. After > 15 years
> > working on
> > the code base, I've not felt the need to go back and make it work
> > in
> > detail.
> > 
> > Vpp uses multiple, independent heaps - some in shared memory - so
> > switching to vanilla malloc() seems like a non-starter.
> > 
> > Vpp's virtual space is larger than one might like - note the
> > difference
> > with none of the plugins loaded - but in terms of real memory
> > consumption
> > we often see RSS sizes in the 20-30mb range. A decent fraction of
> > the
> > virtual space is used to avoid expensive computations in device
> > drivers:
> > to facilitate virtual <--> physical address translation.
> > 
> > Any issues accidentally introduced into the memory allocator would
> > be a
> > severe nuisance. Folks would be well-advised not to tinker with it.
> > 
> > HTH... Dave
> > 
> > -----Original Message-----
> > From: vpp-dev@lists.fd.io <vpp-dev@lists.fd.io> On Behalf Of Elias
> > Rudberg
> > Sent: Monday, September 9, 2019 4:43 AM
> > To: vpp-dev@lists.fd.io
> > Subject: [vpp-dev] How to use valgrind to check for memory errors
> > in vpp?
> > 
> > Hello,
> > 
> > I would like to use valgrind to check for memory errors in vpp.
> > 
> > I understand that running something through valgrind makes it very
> > very
> > slow so that it is not an option for real production usage of vpp.
> > However, valgrind is still very useful for finding errors even if
> > it's
> > only for very limited test runs, so I would very much like to make
> > that
> > work.
> > 
> > I know that vpp has some built-in checking for memory leaks, but
> > the
> > reason I want to use valgrind is not primarily to check for memory
> > leaks
> > but to check for other kinds of memory-access-related errors, like
> > the
> > "invalid read" and "invalid write" errors that valgrind can detect.
> > 
> > So far, what I have done is to build vpp (debug configuration)
> > according
> > to the instructions here: https://fdio-
> > vpp.readthedocs.io/en/latest/gettingstarted/developers/building.htm
> > l
> > Then I stopped the vpp service since I want to run vpp from the
> > command-
> > line through valgrind, and finally I run it like this:
> > 
> > sudo valgrind vpp -c /etc/vpp/startup.conf
> > 
> > That gave warnings about "client switching stacks?" and suggested
> > adding -
> > -max-stackframe=137286291952 so I did that:
> > 
> > sudo valgrind --max-stackframe=137286291936 vpp -c
> > /etc/vpp/startup.conf
> > 
> > Then valgrind gives a warning "Warning: set address range perms:
> > large
> > range" followed by some error reports of the type "Conditional jump
> > or
> > move depends on uninitialised value(s)" inside the mspace_malloc
> > routine
> > in dlmalloc.c.
> > 
> > I think these issues are probably related to the fact that vpp uses
> > its
> > own malloc implementation (in dlmalloc.c) instead of the default
> > malloc,
> > possibly combined with the fact that vpp uses very large (virual)
> > memory.
> > 
> > Questions:
> > 
> > - Are there ways to configure vpp to allow it to work together with
> > valgrind?
> > 
> > - Are there ways to make vpp use less memory? (currently "top"
> > shows
> > 0.205t VIRT memory usage for the vpp_main process)
> > 
> > - Is it possible to somehow configure vpp to use standard malloc
> > instead
> > of the dlmalloc.c implementation, perhaps sacrificing performance
> > but
> > making things work better with valgrind?
> > 
> > Best regards,
> > Elias
> 
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> 
> View/Reply Online (#13929): 
> https://lists.fd.io/g/vpp-dev/message/13929
> Mute This Topic: https://lists.fd.io/mt/34077527/1968077
> Group Owner: vpp-dev+ow...@lists.fd.io
> Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [elias.rudberg@bahn
> hof.net]
> -=-=-=-=-=-=-=-=-=-=-=-
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#13930): https://lists.fd.io/g/vpp-dev/message/13930
Mute This Topic: https://lists.fd.io/mt/34077527/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to