Monday, June 7, 2010

Checking for memory access errors with discover

The latest Solaris Studio Express release contains the tool discover, which tests for memory access errors. These are errors like reading past the end of an array or freeing a pointer twice. The best part of the tool is that it does not require a special build of the application. The sequence is:

$ discover a.out
$ a.out

The discover command adds instrumentation to the executable, and you then run the resulting binary in the same way that you would normally run your program. The output from discover is an html file containing details of any memory access errors that the tool discovered.


3 comments:

  1. Can this detect access past the end of statically allocated arrays?

    ReplyDelete
  2. To answer my own question, I tried it and it does not, although the html lists SBW and SBR. Also the executable needs to be built with -xbinopt=prepare (which itself requires -O) which is not exactly "does not require a special build".

    ReplyDelete
  3. You should not need to build with -xbinopt=prepare, this is on by default. You are correct in that you need optimisation (-xO), but that should be ok. I'll check about the static array accesses.

    Regards,

    Darryl.

    ReplyDelete