Fixing a CinePaint Memory Leak with Valgrind

Valgrind as a possible solution for CinePaint developers fixing memory leaks

By Robin Rowe

Linux Valgrind tool for memory leak debugging

Linux Valgrind tool for memory leak debugging

HOLLYWOOD, CA ( 2011/11/30 – We got a bug report today for CinePaint 1.0 having a memory leak when handling large TIFF files. To fix this we can look to the free Linux debugging tool Valgrind. Here’s the Valgrind Quick Start Guide. For Valgrind to work you need to build CinePaint with debug enabled.

./configure --enable-debug
sudo make install

It might be challenging to use Valgrind due to the way CinePaint loads plug-ins. The issue is that the TIFF plug-in spawns a process under Linux instead of being a DSO/DLL as implemented in the (not presently available) Windows version. Will Valgrind find it difficult to trace across a spawn? The leak is more likely in core than in the TIFF plug-in, so looking in the core may be sufficient. If not…

Building the Linux plug-ins as DLLs is on the to-do list. The obstacles with that are the many Linux build system changes necessary and that the DLL load code (that is in the CinePaint source already bracketed inside #ifdef WIN32), can encounter an endless loop bug. That bug is the main obstacle to a Windows CinePaint release. It may be that Valgrind can help bytracing that bug under Linux, rather than in Windows. The bug is due to a logic error from the retrofit of DLLs into CinePaint, not OS specific.

Memory leak bug to fix:

  • Open a tiff file
  • Crop
  • Gaussian Blur filter
  • Save As…
  • Repeat this twice, and the tiff file module refuses to load

Exit and re-start and all is well again. The above scenario is particularly severe with 70mm film. Each frame is about 450MB. The machine has 6GB of memory. At times, the crash manifests itself as endless loop pegging a whole CPU at 100%. If the crash happens during disk I/O it may take several long, irritating minutes to kill because Linux is not very good at runaway disk consumers.


One Comment
  1. Pingback: Efficient Tips For An Effective Bug Reporting. | Wisdom Health Prosperity

Leave a Reply