Skip to content
This repository has been archived by the owner on Jan 16, 2021. It is now read-only.

dmalloc

Maxwell Krohn edited this page Dec 9, 2011 · 1 revision

Dmalloc Debugging Libraries

Dmalloc is a very handy malloc debugging library by Gray Watson, available in the sfslite-dbg and okws-dbg ports supported by OKWS on FreeBSD, and other other platforms when compiling from source.

How To Use Dmalloc With OKWS

Dmalloc is useful for tracking down memory corruptions such as double-frees, access-after-free, access-unitilized-data and so on. It also helps to find memory leaks. To use dmalloc, first make sure you're linked against the libraries, by either installing the ports described above, or by installing sfslite and okws with the 'shdbg' or 'debug' modes.

Without any further intervention, these compile options turn on several important sanity checks within the SFS libraries. Furthermore, you can turn on runtime dmalloc checks by the appropriate environment variables:

  % dmalloc -i 100 high
  DMALLOC_OPTIONS=debug=0x4f4ed03,inter=100
  export DMALLOC_OPTIONS

In this example, we're asking dmalloc for the environment variables to set a high level of checking, and to do so after ever 100th memory operation (like New, delete, memcpy, etc...) One possible is to set this variable before starting okld, and therefore turn on debugging for all processes in the OKWS suite. A more pinpoint approach is to enable dmalloc just for those services that are causing you grief. For instance, if your okws_config file has this service declaration:

Service signup /signup

And the signup service is crashing mysterious, you can enable dmalloc support on just it by:

Service DMALLOC_OPTIONS=debug=0x4f4ed03,inter=100 singup /signup
Clone this wiki locally