Using LD_PRELOAD wrappers to identify problem use of shared library functions

Daniel P. Berrange berrange at redhat.com
Thu Mar 10 16:40:48 UTC 2011


On Thu, Mar 10, 2011 at 11:25:38AM -0500, William Cohen wrote:
> 
> git repo at:
> 
> http://fedorapeople.org/gitweb?p=wcohen/public_git/memstomp;a=summary
> 
> A fedora scratch package RPM at:
> 
> http://koji.fedoraproject.org/koji/taskinfo?taskID=2898613
> 
> 
> Valgrind does check the arguments for memcpy (and many other memory
> related checks). The main advantage to using the specialized wrappers
> like memstomp is lower overhead. Most people are not willing to pay
> for the overhead that valgrind introduces (4x-100x slow downs). The
> overhead for the memstomp wrappers should be low enough that it would
> be feasible to set the LD_PRELOAD for Fedora alpha releases. This
> would make the problems depending on undefined behavior obvious rather
> than spending a large amount of time trying to replicate the problem
> and then diagnosing it.

There could be problems with the memstomp PRELOAD wrapper function
for any application code which is using memcpy() from within a signal
handler. Functions like fprintf() & malloc() are not async signal
safe, so could deadlock the process or worse. The odds of hitting this
problem are fairly low, but wanted to point out that speed isn't the
only concern wrt enabling a global distro LD_PRELOAD like this.

Regards,
Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|


More information about the devel mailing list