-
Notifications
You must be signed in to change notification settings - Fork 38
dmalloc
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.
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